使用结构功能:
def get_test():
get("/home/wagans/test.txt", "/wagans/test.txt", use_sudo=True)
我获得了“拒绝权限”#39;错误。
完整错误:
Fatal error: get() encountered an exception while downloading '/home/wagans/test.txt'
Underlying exception:
Permission denied
Aborting.
Disconnecting from root@#########... done.
get() encountered an exception while downloading '/home/wagans/test.txt'
Underlying exception:
Permission denied
我是以特定用户身份进行连接,但尝试以root身份进行连接,但仍然收到相同的结果。
输出" ls -l"在remote_path上是:
-rwxrwxrwx 1 root www-data 10 May 4 13:21 test.txt
本地路径文件夹的输出是:
drwxr-xr-x 9 user 306 3 May 17:56 wagans
远程计算机是Ubuntu 14.04,本地是OSX,运行在virtualenv中。
任何人都可以帮我指导解决方案吗? 非常感谢。
答案 0 :(得分:1)
您肯定会尝试在从简单用户权限启动的脚本中使用sudo的权限。因此,您必须使用sudo命令启动脚本。
答案 1 :(得分:0)
我得到了一个非常类似的错误并找到了解决方案:
"yourfile.py" [New File]
Fatal error: get() encountered an exception while
downloading '/home/youruser/foobar'
Underlying exception:
Operation not supported
Aborting.
解决方案不是将文件存储在我的主目录中,该目录具有受限制的权限,您必须在打开的权限目录中存储和检索文件,如/ tmp
以下是有效的代码:
from fabric.operations import get
def fabric_ssh(ip_address, user, password, key_path, verbose=True):
return settings(
host_string=ip_address,
user=user,
key_filename=key_path,
parallel=False,
warn_only=False)
with fabric_ssh("10.0.0.3", "your_user",
"Yourpassword",
"yourkeypath",
True):
get("foobar","/tmp/")
最后,它在下跪后打印成功消息:
[10.130.28.191] download: /tmp/foobar <- /home/youruser/foobar