Update: I suggest trying the command-line lower down to see if the configuration changes proposed will actually work, that way you'll only be making config changes if you've already checked that they'll work.
tl;dr - Add these lines to an ssh config file (personal one typically in .ssh/config
or system-wide one in /etc/ssh/ssh_config
) if you're having this issue connecting to machines (say) alice.example.com
and bob.example.org
,
Host alice.example.com bob.example.org
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
or in more detail:
SSH on Ubuntu and Linux in general normally refers to OpenSSH which now deprecates (and disables by default) the RSA SHA-1 algorithm. It's still available but has to be enabled for the hosts that need it, see their explainer,
When an SSH client connects to a server, each side offers lists of connection parameters to the other... For a successful connection, there must be at least one mutually-supported choice for each parameter.
To be able to connect to hosts with this issue, either or both of the above options are needed (and it's recommended to upgrade the hosts so that they no longer need to use this now-considered-insecure algorithm). In some circumstances you may want to enable these options for all hosts (Host *
).
When you try connecting to a machine, if you see this error message,
Unable to negotiate with ... port 22: no matching host key type found. Their offer: ssh-rsa
that can be fixed with HostkeyAlgorithms +ssh-rsa
When you try connecting to a machine, if you see this error message,
username@some.hostname: Permission denied (publickey).
that may be fixed with PubkeyAcceptedAlgorithms +ssh-rsa
Putting that together gives you a stanza like this (in this case for 2 machines),
Host alice.example.com bob.example.org
PubkeyAcceptedAlgorithms +ssh-rsa
HostkeyAlgorithms +ssh-rsa
You need to add that stanza to either a personal .ssh config file (create it if it doesn't exist) typically in .ssh/config
under your home directory, or if you want any user on your machine to have these settings, add the stanza to /etc/ssh/ssh_config
.
If you don't want to make any configuration changes, you can specify the options on the command line instead,
ssh -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedAlgorithms=+ssh-rsa some.hostname
Finally to note that the PubkeyAcceptedAlgorithms
keyword supercedes PubkeyAcceptedKeyTypes
mentioned in some answers (see "Bugfixes" section in the changelog)