python fabric: put() 导致权限被拒绝

python fabric: put() results in permission denied

我使用面料并拥有:

put('/projects/configuration-management/prototype','/etc/nginx/sites-available')

结果是:

Underlying exception:
    Permission denied

Aborting.

其他配置文件可以轻松上传。我怎样才能避免我的问题?

看起来您需要超级用户权限,运行 使用 sudo 它会正常工作

在文档 (link here) 中说:

While the SFTP protocol (which put uses) has no direct ability to upload files to locations not owned by the connecting user, you may specify use_sudo=True to work around this. When set, this setting causes put to upload the local files to a temporary location on the remote end (defaults to remote user’s $HOME; this may be overridden via temp_dir), and then use sudo to move them to remote_path.