I'm trying to understand why I'm getting a “Permission Denied” error when using paramiko 1.7.6

﹥>﹥吖頭↗ 提交于 2019-12-23 22:23:54

问题


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:

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()

回答1:


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)


来源:https://stackoverflow.com/questions/5849856/im-trying-to-understand-why-im-getting-a-permission-denied-error-when-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!