Error 13 Permission Denied pysftp library

Viewed 183

Error 13 Permission Error to a folder.

I am trying to write a code to upload a document to sftp host using python. I am getting the following error [Error 13] Permission Denied. Can you assist, please? I am using Windows 10 Operating System

import pysftp

hostname = "host.com"
username = "username"
password = "password"

cnopts = pysftp.CnOpts()
cnopts.hostkeys = None 


with pysftp.Connection(host = hostname, username = username, password = password, cnopts=cnopts) as sftp:
    remoteFilePath = r'\Home\FolderName\file.txt'
    localFilePath = r'C:\Users\user\Desktop\file.txt'
    sftp.put(localFilePath,remoteFilePath)

Here's the error that I am getting:

File "<pyshell#23>", line 5, in <module>
    sftp.put(localFilePath,remoteFilePath)
  File "C:\Users\user\\AppData\Roaming\Python\Python39\site-packages\pysftp\__init__.py", line 363, in put
    sftpattrs = self._sftp.put(localpath, remotepath, callback=callback,
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 759, in put
    return self.putfo(fl, remotepath, file_size, callback, confirm)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 714, in putfo
    with self.file(remotepath, "wb") as fr:
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 372, in open
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 813, in _request
    return self._read_response(num)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 865, in _read_response
    self._convert_status(msg)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\paramiko\sftp_client.py", line 896, in _convert_status
    raise IOError(errno.EACCES, text)
PermissionError: [Errno 13] Permission denied
0 Answers
Related