I am accustomed to using Putty on a Windows box or an OSX command line terminal to SSH into a NAS, without any configuration of the client.

Ubuntu 16.04 attempts to SSH into the NAS (via LAN):

ssh [email protected]

Unable to negotiate with port 22: no matching host key type found. Their offer: ssh-dss
  1. Is this result / response intentional?
  2. Is there a simple correction that enables SSH access to the NAS?

10 Answers 10


The version of OpenSSH included in 16.04 disables ssh-dss. There's a neat page with legacy information that includes this issue: http://www.openssh.com/legacy.html

In a nutshell, you should add the option -oHostKeyAlgorithms=+ssh-dss to the SSH command:

ssh -oHostKeyAlgorithms=+ssh-dss [email protected]

You can also add a host pattern in your ~/.ssh/config so you don't have to specify the key algorithm every time:

Host nas

This has the added benefit that you don't need to type out the IP address. Instead, ssh will recognize the host nas and know where to connect to. Of course you can use any other name in its stead.

  • 5
    I believe that these are solutions on the Ubuntu side. Is there a simple option on the NAS side? It would be nice to understand all options and seize the opportunity to harden any security weakness. Maybe this is another question for another thread? Very nice explanation \ response
    – gatorback
    Commented Oct 13, 2016 at 12:31
  • 1
    Is it possible to set this globally? LIke wildcard IP? doesn't work
    – podarok
    Commented Jan 19, 2017 at 14:33
  • 9
    @podarok, try Host *
    – brownian
    Commented May 31, 2017 at 9:25
  • If you're also seeing DH GEX group out of range: serverfault.com/a/809082/55544 Commented Sep 21, 2020 at 16:04
  • 15
    The latest OpenSSH version disables RSA, if you run into the error now, you should use +ssh-rsa instead of +ssh-dss Commented Oct 11, 2021 at 8:27

If you came here because Bitbucket returns the following after an update to OpenSSH 8.8:

Unable to negotiate with <ip address> port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

you should NOT enable DSS (like in the accepted answer), but rather RSA in ~/.ssh/config:

Host bitbucket.org
    HostKeyAlgorithms +ssh-rsa
    PubkeyAcceptedKeyTypes +ssh-rsa

Reference: https://community.atlassian.com/t5/Bitbucket-articles/OpenSSH-8-8-client-incompatibility-and-workaround/ba-p/1826047

Note that PubkeyAcceptedKeyTypes is a backwards compatible alias to PubkeyAcceptedAlgorithms which has been suggested in the article. If you use it, the same configuration can be used with older OpenSSH client versions, e.g. if you share the config with docker containers.

You can do the same for other hosts, or use Host * to allow RSA for any host.

  • 9
    To test on the command line, add this to your ssh command: -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa If that works, edit ~/.ssh/config as described above for that host.
    – bitinerant
    Commented May 13, 2022 at 15:44
  • Did not work for talking to my aging Western Digital NAS.
    – TextGeek
    Commented Jul 14, 2022 at 18:47
  • Worked for my APC Smart-UPS 1000 SMT1000RM2U on firmware UPS 15.0 (ID18) Commented Feb 11 at 12:19

Create new file with *.conf extension in /etc/ssh/ssh_config.d/

sudo nano /etc/ssh/ssh_config.d/my.conf

add to new empty line:

HostKeyAlgorithms ssh-rsa,ssh-dss
PubkeyAcceptedKeyTypes ssh-rsa,ssh-dss
  • Worked for me on Ubuntu 22.02.
    – imuneer
    Commented Sep 11, 2022 at 11:42
  • 2
    You really shouldn't be editing system-wide configuration files when you can just edit the $HOME/.ssh/config file for your own user instead. Commented Aug 1, 2023 at 14:23

If you want to use newer OpenSSH to connect to deprecated servers:

ssh -o KexAlgorithms=diffie-hellman-group14-sha1 -oHostKeyAlgorithms=+ssh-dss my.host.com

Add -v if you want to see what's happening, and -o HostKeyAlgorithms=ssh-dss if it still doesn't work:

ssh -v -o HostKeyAlgorithms=ssh-dss -o KexAlgorithms=diffie-hellman-group14-sha1 my.host.com

You can also edit /etc/ssh/ssh_config or ~/.ssh/ssh_config and add:

Host my.host.com *.myinsecure.net 192.168.1.* 192.168.2.*
    HostKeyAlgorithms ssh-dss
    KexAlgorithms diffie-hellman-group1-sha1    

https://forum.ctwug.za.net/t/fyi-openssh-to-access-rbs-openssh-7/6069 mentions the following fix on Mikrotik Routerboards:

/ip ssh set strong-crypto=yes

(Noting this here because this answer also comes up on web searches when looking for a similar error message.)

  • it should be -o KexAlgorithms=diffie-hellman-group1-sha1 (not 14)
    – dalf
    Commented Sep 8, 2017 at 8:12
  • That depends... $ ssh -Q kex server diffie-hellman-group1-sha1 diffie-hellman-group14-sha1 diffie-hellman-group-exchange-sha1 diffie-hellman-group-exchange-sha256 ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 [email protected]
    – Dagelf
    Commented Sep 10, 2017 at 7:43
  • Thanks for the Mikrotik info. Sadly it only works on RouterOS 6.31 onwards. (Mine is on a remote site and I don't fancy trying a remote upgrade in case something goes wrong...)
    – mwfearnley
    Commented Apr 14, 2020 at 13:36
  • 1
    If adding KexAlgorithms=diffie-hellman-group14-sha1 is more secure with than without, this answer should be the accepted answer Commented Jun 15, 2020 at 1:14
  • 1
    nice! I have received the error "Protocol error: no matching DH grp found". Adding -o KexAlgorithms=diffie-hellman-group14-sha1 helped! (even if it is just a workaround) Commented Sep 1, 2020 at 18:16

Editing the ~/.ssh/config file is the best option. If you have a number of hosts to connect to on the same subnet you can use the following method to avoid entering each host in the file:

 Host 192.168.8.*

This works great for me as I have a number of Brocade switches to manage and they started complaining about the Host key after I moved to Ubuntu 16.04.


For me this added into .ssh\config worked:

Host *
HostkeyAlgorithms +ssh-dss
PubkeyAcceptedKeyTypes +ssh-dss
  • Simple and working. Sometimes you just want a quick solution. Commented Jul 30, 2020 at 14:23

The 'their offer' list of algorithms are the ones that the server will accept so the client needs to offer matching ones. As mentioned one way to fix this is add the missing algorithms to your .ssh/config file. If it still doesn't work it is worth checking which algorithms your version of ssh has to offer:

ssh -Q key

If you do not see the missing algorithm listed from this command then you will need update your ssh version.

But if you do see the missing algorithm there then it's possible that either the system /etc/ssh/ssh_config file and/or /Users/USERNAME/.ssh/config contains a HostkeyAlgorithms line that limits the number of algorithms. This can happen if the algorithms are listed without + prefix which will then lead to ssh only offering those on that list e.g. (HostkeyAlgorithms ssh-dsa) so this can be fixed by just commenting that line, or explicitly adding the specific missing algorithms. The + prefix will add one or more algorithms to the list.


Running this one-liner on client worked to workaround the issue:

echo -e "Host *\nHostKeyAlgorithms +ssh-rsa\nPubkeyAcceptedKeyTypes +ssh-rsa\n"|sudo tee -a ~/.ssh/config


I can't change anything on the server: I created a script called ssh in my home directory which contains:

/usr/bin/ssh -oHostKeyAlgorithms=+ssh-rsa,ssh-dss $1

I can invoke:

./ssh username@host

as before.


I have a different approach since I am working with many different embedded linux systems at work. First I had a script, similar to MichaelM's answer, but I created a special alias that runs ssh with the added parameters (-oHostKeyAlgorithms=+ssh-rsa)

alias sshrsa='function __sshrsa() { PARAM=$*; [ -z "$PARAM" ] && return 1; ssh -oHostKeyAlgorithms=+ssh-rsa ${PARAM}; unset -f __sshrsa; }; __sshrsa'

For this, the alias creates a private function that is then called. This makes it possible to use alias with additional input, which isn't usually supported with alias.

This way I can invoke for example

sshrsa <user>@<host>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .