1

I want to upload a file to a SFTP server using Paramiko, but I don't seem to get it right.
I thought I got the respective error cause of the file path '/' witch is the root on the server but I didn't get anywhare.
I keep getting this error:

  File "c:\python\whitelistBot\whitelistBot.py", line 63, in on_message
    sftp_client.put('C:/python/whitelistBot/whitelist1.json', '/')
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 759, in put
    return self.putfo(fl, remotepath, file_size, callback, confirm)
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 714, in putfo
    with self.file(remotepath, "wb") as fr:
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 372, in open
    t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 813, in _request
    return self._read_response(num)
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 865, in _read_response
    self._convert_status(msg)
  File "C:\python\whitelistBot\lib\site-packages\paramiko\sftp_client.py", line 898, in _convert_status
    raise IOError(text)
OSError: Operation Unsupported

The code I'm running:

import paramiko


FTP_HOST = "********"
FTP_USER = "********"
FTP_PASS = "********"
FTP_PORT = ****

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect(hostname= FTP_HOST, username=FTP_USER, password=FTP_PASS, port=FTP_PORT)
sftp_client = ssh_client.open_sftp()

sftp_client.put('C:/python/whitelistBot/whitelist1.json', '/')

sftp_client.close()
ssh_client.close()

EDIT: I changed the directory where to put the file to "/home/container" cause that's what they told me in the site but except for the fact that I don't get that error message, the file does not appear on the server

0

1 Answer 1

0

Looks like I had to specify the name of the file '/whitelist1.json' like so:

sftp_client.put('C:/python/whitelistBot/whitelist1.json', '/whitelist1.json') # don't know why but yeah
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.