sftp put权限不够

时间:2024-06-13 19:06:14

报错如下:

sftp> put play.zip ./
Uploading play.zip to /opt/library/./play.zip
remote open("/opt/library/./play.zip"): Permission denied

原因:
sftp登录以后当前所在目录的owner不是sftp登录者,也就是说当前目录没有write权限,so修改权限,再put上传。如下:

$ sudo chown xuyuzhu -R ./      # ssh登录以后修改目录owner
$ exit
登出
$ sftp xuyuzhu@192.168.63.9 # 重新登录sftp
xuyuzhu@192.168.63.9's password:
Connected to 192.168.63.9.
sftp> cd /opt # 进入要上传的目录
sftp> put play.zip # 上传
Uploading play.zip to /opt/library/play.zip
play.zip 100% 74MB 10.6MB/s 00:07