I am trying to connect to a server using pysftp
to transfer files.
Whenever I run
con = pysftp.Connection('ftp.abc.com', username='user', password='my_pass')
I get the SSHException
saying incompatible ssh server, which is most probably due to the compression used (or not used).
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pysftp.py", line 162, in __init__
self._transport.connect(username=username, password=password)
File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 978, in connect
self.start_client()
File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 406, in start_client
raise e
SSHException: Incompatible ssh server (no acceptable compression) [] [] ('none',)
It is not a problem with the server itself because when I run sftp -v ftp.abc.com
, I get the following output:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
...
debug1: Connection established.
...
...
...
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version JSCAPE
debug1: no match: JSCAPE
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client 3des-cbc hmac-md5 zlib
debug1: kex: client->server 3des-cbc hmac-md5 zlib
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: ...
debug1: Host ... is known and matches the RSA host key.
debug1: Found key in /home/.../.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: Enabling compression at level 6.
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: password
debug1: Next authentication method: password
And it works fine after entering the password.
I did some reading and tried sftping into the server without compression, but I was unable to. It'd always enable compression even after I changed the ssh_config
file and specified -oCompression=no
at the commandline.
So, how do I connect without using compression, and more importantly, is there a way to use pysftp with compression level set to 6?
I sorted out the paramiko part.
I downloaded the source code and then I had to change the _preferred_compression
to zlib
. It is set to none
by default.
In line number 102 in paramiko/transport.py, I changed the line
_preferred_compression = ('none',)
to
_preferred_compression = ('zlib',)
It worked, but I have no idea why paramiko is unable to negotiate to it.
And the part about running sftp
without compression still remains answered.
Any help will be appreciated.