1

After upgrading to Debian 10 (Buster) I can no longer connect to a SFTP server

no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 Connection closed

sftp -b - -o StrictHostKeyChecking=no -i private.key -P 10022 user@host

sftp -vv ... returns

OpenSSH_7.9p1 Debian-10, OpenSSL 1.1.1c  28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "host" port 10022
debug2: ssh_connect_direct
debug1: Connecting to host [92.60.159.16] port 10022.
debug1: Connection established.
debug1: identity file /var/www/bs_id_rsa type -1
debug1: identity file /var/www/bs_id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10
debug1: Remote protocol version 2.0, remote software version IBM Sterling Connect:Enterprise for UNIX2.5.00
debug1: no match: IBM Sterling Connect:Enterprise for UNIX2.5.00
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to host:10022 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ssh-dss
debug2: ciphers ctos: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-md5,hmac-sha1,hmac-ripemd160,hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none,zlib
debug2: compression stoc: none,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: (no match)
Unable to negotiate with xx.xx.xx.xx port 10022: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
Connection closed.
Connection closed

Keys ssh -Q kex

diffie-hellman-group1-sha1
diffie-hellman-group14-sha1
diffie-hellman-group14-sha256
diffie-hellman-group16-sha512
diffie-hellman-group18-sha512
diffie-hellman-group-exchange-sha1
diffie-hellman-group-exchange-sha256
ecdh-sha2-nistp256
ecdh-sha2-nistp384
ecdh-sha2-nistp521
curve25519-sha256
curve25519-sha256@libssh.org

with KexAlgorithms:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -i private.key -p 10022 user@host
Unable to negotiate with 92.60.159.16 port 10022: no matching host key type found. Their offer: ssh-dss

with HostKeyAlgorithms:

ssh -oHostKeyAlgorithms=ssh-dss -oKexAlgorithms=+diffie-hellman-group1-sha1 -i private.key -p 10022 user@host
Unable to negotiate with 92.60.159.16 port 10022: no matching cipher found. Their offer: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc

SSH working

ssh -oHostKeyAlgorithms=ssh-dss -oKexAlgorithms=+diffie-hellman-group1-sha1 -oCiphers=aes256-cbc -i private.key -p 10022 user@host
  • Did I get all parameters in my answer correct? – Ned64 Aug 6 at 16:07
  • I prefer the command line variation.. It's too complicated to add hosts to ssh/config – clarkk Aug 6 at 16:11
  • If you connect to the host more than once the config file option may be more convenient (especially if someone writes it for you). Does the answer have all options you need now? If not, let me know so that I can complete it. EDIT: Added a commandline option so that people can find the working method in the answer. Thanks @user4556274 for helping find these options while I typed the answer! – Ned64 Aug 6 at 16:15
3

Add host specific parameters to your ~/.ssh/config file (start with an empty file if it does not exist yet) like this:

Host host.somewhere.dk
  Hostname host.somewhere.dk
  KexAlgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
  IdentityFile ~/.ssh/private.key
  Ciphers aes256-cbc
  HostKeyAlgorithms ssh-dss
  Port 10022
  User user

Optionally, if you do not wish to use a config file, write the host specific options into a commandline:

ssh -oHostKeyAlgorithms=ssh-dss -oKexAlgorithms=diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1 -oCiphers=aes256-cbc -i ~/ssh/private.key -p 10022 user@host

Please also note that in both cases, port numbers above 1024 are considered unsafe for system services because any (non-privileged) user can open such a high port. Better use a lower, privileged port.

  • Please note that user4556274 has gone through multiple back & forth conversations with clarkk regarding additional ssh options that became required. – Jeff Schaller Aug 6 at 16:04
  • @JeffSchaller OK, thanks - took me too long to write my answer, apparently :-) – Ned64 Aug 6 at 16:04
  • 2
    I'd vote this answer if it expanded to include the other particular parameters needed for the OP (Ciphers, HostKeyAlgorithms), as well as the generic background (older server using multiple deprecated options, use of ssh -Q ... to manually select supported but non-default options on the client which match the server. The config block is obviously superior to the iterative command line expansions as the conflicts were resolved piecemeal. – user4556274 Aug 6 at 16:07
  • @user4556274 Added some more now, please check and let me know! – Ned64 Aug 6 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.