key type ssh-rsa not in pubkey accepted algorithms

I was running Ubuntu 20.04 happily, and then over the weekend decided to back everything up and install 22.04. I installed my previous keys but I couldn’t login via MobaXTerm remotely as I usually did with 20.04.

I logged in with a console and checked /var/log/auth.log . Here are the messages generated upon my tries to log in:

The root cause of this error “key type ssh-rsa not in pubkey accepted algorithms” is that ssh-rsa key considered not safe anymore.

The RSA SHA-1 hash algorithm is being quickly deprecated across operating systems and SSH clients because of various security vulnerabilities, with many of these technologies now outright denying the use of this algorithm.

It seems this has happened for the ssh client in Ubuntu 22.04. The RSA public-private key pair is considered not safe any more.

Solution

Use a more modern and secure type of key such as ed25519. Generate a new key pair in your Ubuntu 22.04 computer with this command:

Note: the string after -C is a comment it is customary to put your email address here. Since you may only be using this key within your home, putting the email address may not make sense. I would put something like “colin@colin-desktop” so that you know which user and computer the key belongs to within your household.

Alternately you may create a new RSA key with SHA2 hashing like so:

Either way you will need to use the ssh-copy-id command again:

This command will recognize there is a new public key and copy the new key to the /root/.ssh/authorized_keys file.

It should work now.

A Remote Server Workaround

If you can’t change anything on the local computer, or don’t want to use a new key, and want to re-enable RSA on the local computer, edit the file /etc/ssh/sshd_config on the remote computer and add this line:

This will allow the use of unsafe RSA key you already have.

Remember to restart the sshd service by:

Otherwise you will have to restart your computer to make the change take effect.

More information

Want me to do this for you? Drop me a line: itgalaxyzzz {at} gmail [point] com