Open ghost opened 7 years ago
Just to add on to this While sending the packet with version 3 in sftp_client.py, it receives \r \n in response and paramiko says it is a garbage value , please see the attached snap shot.
x = self._read_all(4)
# most sftp servers won't accept packets larger than about 32k, so
# anything with the high byte set (> 16MB) is just garbage.
if byte_ord(x[0]):
raise SFTPError('Garbage packet received')
if i put below code snip in library. it resolves the issue,
def _read_packet(self): x = self._read_all(4) y = bytes() index0 = False index1 = False if(len(x) > 0): if x[0] == '\r': index0 = True if x[1] == '\n': index1 = True
if index0 and index1:
y = self._read_all(2)
x = x[2:4] + y
elif index0:
y = self._read_all(1)
x = x[1:4] + y
elif index1:
y = self._read_all(1)
x = x[0] + x[2:4] + y
Regards Mahesh
I am using the paramiko library in order to transfer the file from Device to my server. But having the trouble when there is a security tools like tacacs and radius is configured. it fails to open the sftp connection. Although in case of Device which does not have the tacacs and Radius configured it works file . any thing we have to provide extra parameter.
The code i am using given below
client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect("Ip ADDRESS", username='user', password='pass') sftp = client.open_sftp() ## Says garbage packet received from the server. below is the exception
File "/vagrant/xyx/bxyx/wsutil.py", line 14, in download sftp = client.open_sftp() File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/client.py", line 477, in open_sftp return self._transport.open_sftp_client() File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/transport.py", line 919, in open_sftp_client return SFTPClient.from_transport(self) File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 132, in from_transport return cls(chan) File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/sftp_client.py", line 99, in init server_version = self._send_version() File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/sftp.py", line 105, in _send_version t, data = self._read_packet() File "/vagrant/xyx/env/lib/python2.7/site-packages/paramiko/sftp.py", line 179, in _read_packet raise SFTPError('Garbage packet received') SFTPError: Garbage packet received
We would be grateful if any one can help in that .
if i check the packet in debug i receive the \r\n in 4 byte packet that raises the exception.
Normal SFTP works fine when we use the terminal in order to transfer the file.