Python Forum
SFTP transfer using paramiko fails
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SFTP transfer using paramiko fails
#1
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:

Output:
PS C:\00Python> python .\pysftp.py Traceback (most recent call last): File ".\pysftp.py", line 9, in <module> sftp.put('ipsec_monitoringv2.py','/ipsec_monitoringv2.py') File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 727, in put return self.putfo(fl, remotepath, file_size, callback, confirm) File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 683, in putfo with self.file(remotepath, 'wb') as fr: File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 341, in open t, msg = self._request(CMD_OPEN, filename, imode, attrblock) File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 780, in _request return self._read_response(num) File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", line 832, in _read_response self._convert_status(msg) File "C:\Python27\lib\site-packages\paramiko\sftp_client.py", 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:/ipsec_monitoringv2.py', '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

Code:

import paramiko
import subprocess
 
ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh_client.connect('10.0.0.1', 22, 'python', 'python')
sftp = ssh_client.open_sftp()
 
sftp.put('test.py','/test.py')
 
sftp.close()
ssh_client.close()
Reply


Messages In This Thread
SFTP transfer using paramiko fails - by estebanup03 - Sep-06-2018, 08:06 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  no such file or directory in SFTP saisankalpj 2 1,493 Nov-25-2022, 11:07 AM
Last Post: DeaD_EyE
  file transfer via python SFTP SCP mg24 3 2,875 Sep-15-2022, 04:20 AM
Last Post: mg24
  Opening CSV file from SFTP server not working cluelessintern 0 2,728 Apr-08-2020, 08:10 PM
Last Post: cluelessintern
  Connect to SFTP to read cvs files arunlal 1 2,990 Nov-20-2018, 08:32 AM
Last Post: buran
  get file paramiko sftp Reyneli 0 3,006 Jun-29-2018, 08:25 AM
Last Post: Reyneli
  Watch SFTP Folder torz 2 9,110 Dec-02-2017, 01:42 AM
Last Post: torz

Forum Jump:

User Panel Messages

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