windows 我试图理解为什么在使用 paramiko 1.7.6 时会收到“权限被拒绝”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5849856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm trying to understand why I'm getting a "Permission Denied" error when using paramiko 1.7.6
提问by suffa
Can anyone tell me why I'm getting the following error:
谁能告诉我为什么我收到以下错误:
Traceback (most recent call last):
File "C:\Python27\connect.py", line 22, in <module>
sftp.get(filepath, localpath)
File "C:\Python27\lib\site-packages\paramiko-1.7.6-py2.7.egg\paramiko\sftp_client.py", line 603, in get
fl = file(localpath, 'wb')
IOError: [Errno 13] Permission denied: 'C:\remote'
I'm using Python 2.7 on a Windows 7 (as administrator) machine logging into an Ubuntu 10.10 machine. Here is the, very straight forward, script that I'm using:
我在登录 Ubuntu 10.10 机器的 Windows 7(以管理员身份)机器上使用 Python 2.7。这是我正在使用的非常直接的脚本:
import paramiko
import os
paramiko.util.log_to_file('c:\Python27\paramiko-wininst.log')
host = '192.168.1.14'
port = 22
transport = paramiko.Transport((host,port))
password = 'xxxxxx'
username = 'username'
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/home/my.log'
localpath = 'C:\remote'
sftp.get(filepath, localpath)
sftp.close()
transport.close()
回答by 3xt
Try to make the following change
尝试进行以下更改
localpath = 'C:\remote'
sftp.get(filepath, localpath)
modify it to
修改为
localpath = 'C:\remote\my.log'
sftp.get(filepath, localpath)