Python paramiko SFTP IOError
I am trying to create a python script that connects to my server and sends some files via SFTP. But the problem is I keep getting
IOError: Failure
Does anyone know why this is happening? The directory on my local PC has multiple files.
code:
import paramiko
import os
local_path = "/home/user/Desktop/test"
remote_path = "/home/user/files/html/"
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ipaddress', username="user", password="user")
sftp = ssh.open_sftp()
for root, dirs, files in os.walk(local_path):
for fname in files:
full_fname = os.path.join(root, fname)
sftp.put(full_fname, remote_path)
sftp.close()
ssh.close()
Traceback:
Traceback (most recent call last):
File "ftp_test.py", line 16, in <module>
sftp.put(full_fname, remote_path)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 669, in put
return self.putfo(fl, remotepath, file_size, callback, confirm)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 621, in putfo
with self.file(remotepath, 'wb') as fr:
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 327, in open
t, msg = self._request(CMD_OPEN, filename, imode, attrblock)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 729, in _request
return self._read_response(num)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 776, in _read_response
self._convert_status(msg)
File "/usr/local/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 806, in _convert_status
raise IOError(text)
IOError: Failure
+3
source to share