SFTPError: Garbage packet received

Bug #596399 reported by Nikolaus Rath
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
paramiko
New
Undecided
Unassigned

Bug Description

When I'm trying to upload data using SFTPClient, I almost always immediately get the following error:

  File "/home/nikratio/projekte/s3ql/src/s3ql/backends/sftp.py", line 52, in __contains__
    self.sftp.stat(entry)
  File "/usr/lib/pymodules/python2.6/paramiko/sftp_client.py", line 337, in stat
    t, msg = self._request(CMD_STAT, path)
  File "/usr/lib/pymodules/python2.6/paramiko/sftp_client.py", line 628, in _request
    return self._read_response(num)
  File "/usr/lib/pymodules/python2.6/paramiko/sftp_client.py", line 658, in _read_response
    t, data = self._read_packet()
  File "/usr/lib/pymodules/python2.6/paramiko/sftp.py", line 179, in _read_packet
    raise SFTPError('Garbage packet received')

I am able to transfer the files without problems when using scp, sshfs or sftp. Normal ssh access works fine too. Only Paramiko seems to fail.

This happens on at least two systems:

debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH*

and

debug1: Remote protocol version 2.0, remote software version OpenSSH_3.7.1p2
debug1: match: OpenSSH_3.7.1p2 pat OpenSSH_3.*

I am using Paramiko 1.7.6-2 (Ubuntu Lucid).

Revision history for this message
Jonathan Gilligan (jonathan-gilligan) wrote :

I see the same thing, but only under certain circumstances. Connecting to

Authenticating with a password works fine:

>>> transport = paramiko.Transport((host, port))
>>> transport.connect()
>>> transport.remote_version
'SSH-2.0-OpenSSH_4.3p2 Debian-5~bpo.1.netgear1'
>>> transport.auth_password(username=user, password=passwd)
[]
>>> sftp = transport.open_sftp_client()

Success. Working sftp client.

Authenticating with a public key fails:

>>> transport = paramiko.Transport((host, port))
>>> transport.connect()
>>> transport.auth_publickey(username=user, key=keys[0])
[]
>>> transport.authenticated
True
>>> sftp = transport.open_sftp_client()
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\paramiko-1.7.4-py2.7.egg\paramiko\transport.py", line 809, in open_sftp_client
    return SFTPClient.from_transport(self)
  File "C:\Python27\lib\site-packages\paramiko-1.7.4-py2.7.egg\paramiko\sftp_client.py", line 105, in from_transport
    return cls(chan)
  File "C:\Python27\lib\site-packages\paramiko-1.7.4-py2.7.egg\paramiko\sftp_client.py", line 86, in __init__
    server_version = self._send_version()
  File "C:\Python27\lib\site-packages\paramiko-1.7.4-py2.7.egg\paramiko\sftp.py", line 108, in _send_version
    t, data = self._read_packet()
  File "C:\Python27\lib\site-packages\paramiko-1.7.4-py2.7.egg\paramiko\sftp.py", line 179, in _read_packet
    raise SFTPError('Garbage packet received')
SFTPError: Garbage packet received
>>>

This error is 100% reproducible on this system (every time I authenticate with password, creating an sftp client succeeds, and every time I authenticate with a public key, creating an sftp client fails). I can sftp successfully using public key authentication with other sftp clients, including Putty and Bitvise Tunnelier.

Revision history for this message
Pedro guridi (pedro-guridi) wrote :

Im getting exactly the same crash, authenticating with RSA public key:

>>> t = paramiko.Transport((hostname, port))
>>> t.start_client()
>>> transport.remote_version
 'SSH-2.0-OpenSSH_5.8'
>>> sftp = paramiko.SFTPClient.from_transport(t)
Traceback (most recent call last):
  File "scp.py", line 52, in <module>
    sftp = paramiko.SFTPClient.from_transport(t)
  File "C:\python26\lib\site-packages\paramiko\sftp_client.py", line 106, in from_transport
    return cls(chan)
  File "C:\python26\lib\site-packages\paramiko\sftp_client.py", line 87, in __init__
    server_version = self._send_version()
  File "C:\python26\lib\site-packages\paramiko\sftp.py", line 108, in _send_version
    t, data = self._read_packet()
  File "C:\python26\lib\site-packages\paramiko\sftp.py", line 179, in _read_packet
    raise SFTPError('Garbage packet received')
paramiko.SFTPError: Garbage packet received

Running with python 2.6.6, under windows xp 32 bits.
Remote machine running Fedora 16 Verne, 64bits.

Revision history for this message
Raf Geens (raf-geens) wrote :

I'm getting the same error when uploading over SFTP between two Centos 5.7 64-bits machines. It worked for a long while when I was only uploading files every 10 seconds or so. For a stress test I was serially uploading files of 0 bytes as fast as possible and then I started getting "Garbage packet received"errors. All subsequent transfer attempts after that point fail. This is also using public key authentication. Paramiko version is 1.7.7.1.

Revision history for this message
Raf Geens (raf-geens) wrote :

I've found a trigger for my issue: I had set up the user on the SSH server with a /sbin/nologin shell. When I switched that to /bin/bash, Paramiko transferred just fine.

Revision history for this message
Torsten Landschoff (torsten) wrote :

I just had a support request because of this error. In this case, the reason was that some .cshrc script started a job in the background which was writing to stdout and stderr. Somehow this was mangled into the sftp service output.
Solution: Don't start garbage processes in .cshrc ;-)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.