trying to download some files from windows server using sftp in paramiko. get method is:
def get(self, remotepath, localpath = None):
"""Copies a file between the remote host and the local host."""
if not localpath:
localpath = os.path.split(remotepath)[1]
self._sftp_connect()
self._sftp.get(remotepath, localpath)
On running the script as
sshObj.get('C:\\my_file.txt', 'D:\\python\\')
, it throws the error :
File "C:\Py34\lib\site-packages\paramiko\sftp_client.py", line 806, in _convert_status
raise IOError(errno.EACCES, text)`PermissionError: [Errno 13] **Permission denied**`
I have given all the permissions to the folder. also shared it with other users. But still the error is there. Any leads if anyone has faced this before will be helpful.
Note: I installed freesshd to make my localbox an ssh server.
It is not about the path naming convention.
In the local path, you did not mention the file name, you have just mentioned the directory to save the file.
Use:
sshObj.get('C:\\my_file.txt', 'D:\\python\\my_file.txt')
instead of
sshObj.get('C:\\my_file.txt', 'D:\\python\\')
Thanks All! Finally I found the answer. It was because of the format of the filepaths.
On trying sshObj.get("/remote_file.txt","C:/tmp/local_file.txt")
it succeded without any error.
Download the tool winSCP, it has a good GUI which will help you understand the format of file paths properly.
Also check your base SFTP folder on the remote machine because in my case the error was thrown because remote_file.txt
was not located at the root sftp folder(which can be configured manually) on the remote box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With