Ssh-rsa key algorithm not accepted in Rocky 9.4

Hi Team,

I have recently upgraded one of my server from Centos7.9 to Rocky 9.4.

After upgrading the server, I get the below error if I try to ssh to the server from another CentOS 7.9 server.

Unable to negotiate with xxx.xxx.xxx.xx port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

Tried below solution, but nothing found to be working.

  1. PubkeyAcceptedAlgorithms=+ssh-rsa (add in sshd_config)
  2. Tried SSH using below command;

ssh -vvv -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedKeyTypes=+ssh-rsa root@xxx.xxx.xxx.xx

Any suggestion how to make Rocky9 accept ssh-rsa key algorithm?

Thanks,
Scott

If you look at sshd.service in Rocky 9 – with:

cat /usr/lib/systemd/system/sshd.service

you should see that the service wants sshd-keygen.target and that in turn:

Wants=sshd-keygen@rsa.service
Wants=sshd-keygen@ecdsa.service
Wants=sshd-keygen@ed25519.service

In other words, the Rocky 9 system should have RSA, ECDSA, and ED25519 host keys, or else the sshd would refuse to start.
Furthermore, running sudo sshd -T | grep hostkey on the Rocky 9 should show plenty – but not ssh-dsa nor ssh-rsa.


If you have default ‘sshd_config’ in el9, then you have only three (actual) lines in it:

$ sudo grep "^[^#]" /etc/ssh/sshd_config
Include /etc/ssh/sshd_config.d/*.conf
AuthorizedKeysFile	.ssh/authorized_keys
Subsystem	sftp	/usr/libexec/openssh/sftp-server

The first reads additional files (in alphabetical order). One of them does:
Include /etc/crypto-policies/back-ends/opensshserver.config
that file sets the ‘PubkeyAcceptedAlgorithms’.
Does that include “ssh-rsa”? If not, does sshd -T show that your addition
takes effect? (SSH uses/prefers first occurrence.)

The algorithms can be adjusted with Chapter 3. Using system-wide cryptographic policies | Red Hat Product Documentation
i.e. update-crypto-policies --set DEFAULT:SHA1

However, I can right now ssh from el7 to el9, where the el9 has policy DEFAULT. The ssh client on the el7 did store ECDSA hostkey of el9 to knownhosts.

One more thing:
I do hope that by “upgrade” you do mean fresh install of Rocky 9, and not any dark magick.

One more thing to consider would be the key length of the RSA pubkey. I have seen servers reject if it wasn’t 2048 or higher. Perhaps it’s an old generated ssh-key that is too short?

I missed conectiva for its distro upgrade - and downgrade - versatility, just with apt4rpm (another best-of-breed over DidNotFinish). Wow, did that work a treat.

That is quite true. Alas, the error message would be different:

[me@el9 ~]$ ssh old-server-with-short-rsa-key
Bad server host key: Invalid key length

[me@el9 ~]$ ssh -o RSAMinSize=1024 old-server-with-short-rsa-key
[me@old-server-with-short-rsa-key ~]$

Are you sure you have an RSA key and that’s what you’re actually sending? From the server message, it clearly says it accepts RSA. Why don’t you just generate a new RSA key with ssh-keygen -t rsa and try that? On some systems, it defaults to Ed25519 so you need to explicitly set it to RSA.

What is the output of ssh -v when you connect?

Just in case you’re actually using Ed25519, you should know it won’t work if the OS is running in FIPS mode.