Python Forum
SFTP transfer using paramiko fails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SFTP transfer using paramiko fails
Hi Amigos,

I need to automate a file transfer via SFTP to several devices and i have found thousands of code using paramiko i am not very experienced with python and i took the code below but is not working i have done a lot of debugs and it seems a problem with paths but i have tried a lot of things and couldnt solve it, appreciate your kind help with any recommendation.

Details: Code error execution as follows:

PS C:\00Python> python .\ Traceback (most recent call last): File ".\", line 9, in <module> sftp.put('','/') File "C:\Python27\lib\site-packages\paramiko\", line 727, in put return self.putfo(fl, remotepath, file_size, callback, confirm) File "C:\Python27\lib\site-packages\paramiko\", line 683, in putfo with self.file(remotepath, 'wb') as fr: File "C:\Python27\lib\site-packages\paramiko\", line 341, in open t, msg = self._request(CMD_OPEN, filename, imode, attrblock) File "C:\Python27\lib\site-packages\paramiko\", line 780, in _request return self._read_response(num) File "C:\Python27\lib\site-packages\paramiko\", line 832, in _read_response self._convert_status(msg) File "C:\Python27\lib\site-packages\paramiko\", line 865, in _convert_status raise IOError(text) IOError
TSHOOT: I´ve checked paramiko generated log and i can see the following error:

DEB [20180906-11:57:27.368] thr=1 paramiko.transport: Kex agreed: diffie-hellman-group-exchange-sha1
DEB [20180906-11:57:27.368] thr=1 paramiko.transport: HostKey agreed: ssh-rsa
DEB [20180906-11:57:27.368] thr=1 paramiko.transport: Cipher agreed: aes128-ctr
DEB [20180906-11:57:27.368] thr=1 paramiko.transport: MAC agreed: hmac-sha2-256
DEB [20180906-11:57:27.368] thr=1 paramiko.transport: Compression agreed: none
DEB [20180906-11:57:27.539] thr=1 paramiko.transport: Got server p (2048 bits)
DEB [20180906-11:57:28.223] thr=1 paramiko.transport: kex engine KexGex specified hash_algo <built-in function openssl_sha1>
DEB [20180906-11:57:28.223] thr=1 paramiko.transport: Switch to new keys ...
DEB [20180906-11:57:28.255] thr=2 paramiko.transport: Attempting password auth...
DEB [20180906-11:57:28.499] thr=1 paramiko.transport: userauth is OK
INF [20180906-11:57:29.130] thr=1 paramiko.transport: Authentication (password) successful!
DEB [20180906-11:57:29.154] thr=2 paramiko.transport: [chan 0] Max packet in: 32768 bytes
DEB [20180906-11:57:29.332] thr=1 paramiko.transport: [chan 0] Max packet out: 32768 bytes
DEB [20180906-11:57:29.334] thr=1 paramiko.transport: Secsh channel 0 opened.
DEB [20180906-11:57:29.403] thr=1 paramiko.transport: [chan 0] Sesch channel 0 request ok
INF [20180906-11:57:29.549] thr=2 paramiko.transport.sftp: [chan 0] Opened sftp connection (server version 3)
DEB [20180906-11:57:29.555] thr=2 paramiko.transport.sftp: [chan 0] open('sd1:/', 'wb')
DEB [20180906-11:57:29.838] thr=1 paramiko.transport: EOF in transport thread

System info: Windows 10 64 bit Python 2.7.15


import paramiko
import subprocess
ssh_client = paramiko.SSHClient()
ssh_client.connect('', 22, 'python', 'python')
sftp = ssh_client.open_sftp()

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script to call oracle function and sftp result as pipe delimited text file tejkrishna 1 164 Dec-31-2020, 04:12 PM
Last Post: Larz60+
  Opening CSV file from SFTP server not working cluelessintern 0 587 Apr-08-2020, 08:10 PM
Last Post: cluelessintern
  Connect to SFTP to read cvs files arunlal 1 1,065 Nov-20-2018, 08:32 AM
Last Post: buran
  get file paramiko sftp Reyneli 0 1,524 Jun-29-2018, 08:25 AM
Last Post: Reyneli
  Watch SFTP Folder torz 2 4,706 Dec-02-2017, 01:42 AM
Last Post: torz

Forum Jump:

User Panel Messages

Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020