3

I'm trying to enable ssh-rsa (eventually just for one host) but the changes I make don't seem to be working with OpenSSH 8.7 on Amazon Linux 2023.

First, I added these lines to the bottom of /etc/ssh/sshd_config:

HostKeyAlgorithms +ssh-rsa PubkeyAcceptedAlgorithms +ssh-rsa 

After restarting sshd, I ran sshd -T but I only see ssh-rsa added to the end of the pubkeyacceptedalgorithms line, not the hostkeyalgorithms line.

I then removed the two lines above and tried modifying /etc/crypto-policies/back-ends/opensshserver.config, which is (eventually) included by /etc/ssh/sshd_config. I added ssh-rsa to the HostKeyAlgorithms and PubkeyAcceptedAlgorithms lines:

HostKeyAlgorithms ssh-rsa,ecdsa-sha2-nistp256,[email protected],[email protected],[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected]

PubkeyAcceptedAlgorithms ssh-rsa,ecdsa-sha2-nistp256,[email protected],[email protected],[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected]

After restarting sshd, I ran sshd -T and got the following, which looked good:

hostkeyalgorithms ssh-rsa,ecdsa-sha2-nistp256,[email protected],[email protected],[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected]

pubkeyacceptedalgorithms ssh-rsa,ecdsa-sha2-nistp256,[email protected],[email protected],[email protected],ecdsa-sha2-nistp384,[email protected],ecdsa-sha2-nistp521,[email protected],ssh-ed25519,[email protected],[email protected],[email protected],rsa-sha2-256,[email protected],rsa-sha2-512,[email protected]

But when I try to ssh to the server with ssh-rsa, it fails, and the debug lines show different settings coming from the server:

> ssh -vvv -oHostKeyAlgorithms=ssh-rsa localhost ... debug2: local client KEXINIT proposal debug2: host key algorithms: ssh-rsa ... debug2: peer server KEXINIT proposal debug2: host key algorithms: ecdsa-sha2-nistp256,ssh-ed25519 

Why does the server report only supporting ecdsa-sha2-nistp256,ssh-ed25519, and not the rest of the algorithms included in /etc/crypto-policies/back-ends/opensshserver.config or in sshd -T?

And why doesn't it work to add the "+" lines to the bottom of /etc/ssh/sshd_config?

I also tried running update-crypto-policies --set LEGACY, which modified the opensshserver.config file, but it had the same result as editing the file directly.

Thanks for any help!

UPDATE: I got it working! See the first comment on this post from dave_thompson_085 below, and my comment just after his.

3
  • 1
    Check if your server has (1) a file /etc/ssh/ssh_host_rsa_key with correct owner and permissions and containing an RSA key and (2) in the config, directly or via crypto-policies, either a HostKey entry for that file or no HostKey entries at all (thus using the default) Commented Jun 15, 2024 at 23:14
  • @dave_thompson_085: Thank you! The new Amazon Linux 2023 servers don't come with the rsa key file, but that was quickly copied from an older server. Also, all of the HostKey lines were commented out, which (I guess?) explains why the default host key algorithms were used. I now have it working! Please write your comment above as an answer and I'll be happy to select it. Bonus if you're able to explain: 1) how to support ssh-rsa for a single client, or 2) why HostKeyAlgorithms +ssh-rsa has to go before the other config files are included, since I thought "+" meant to add it to the end. Commented Jun 16, 2024 at 2:55
  • I just saw this because of the necro; I don't know why I didn't before. (1) you can apply a config-item to only selected client(s) using a Match block; see the manpage (2) for most config-items (HostKey is an exception) only the first occurrence i.e. line is used, so if sshd_config already had a HostKeyAlgorithm line (which I expect it effectively did with RH-style policy) and you added another such line below that one the new one is ignored; with Match block(s) this is modified to the first 'global' occurrence or the first occurrence in a selected Match block if any. Commented Jul 5 at 3:28

1 Answer 1

2

It is a security concern. OpenSSH 8.7 by default disables the ssh-rsa key exchange algorithm.

OpenSSH will disable the ssh-rsa signature scheme by default in the next release.

In the SSH protocol, the "ssh-rsa" signature scheme uses the SHA-1 hash algorithm in conjunction with the RSA public key algorithm. It is now possible1 to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K.

That is mentioned in AL2023 Security updates and features

SSH server default

AL2023 includes OpenSSH 8.7. OpenSSH 8.7 by default disables the ssh-rsa key exchange algorithm. For more information, see Default SSH server configuration.

You might also want to look at Connect to your Linux instance.

If you insist on reducing security then a possible answer might be on Unix & Linux SE: How to enable ssh-rsa in sshd of OpenSSH 8.8?

3
  • Thanks, yes, I'm aware that the latest versions of OpenSSH disable ssh-rsa, but I have a need for enabling it for one host. Also, thanks for the link to the other answer, but I've seen that as well. It actually suggests doing what I did with the "+" lines in sshd_config, but on my server, that doesn't change what my server reports to the client as far as supported algorithms. Commented Jun 15, 2024 at 16:01
  • @RussellG How about this: docs.aws.amazon.com/linux/al2023/ug/ssh-host-keys-disabled.html ? Commented Jun 15, 2024 at 17:02
  • Thanks, but I've seen that page as well. It led me to trying update-crypto-policies but that only changed the same files I was changing myself. Commented Jun 15, 2024 at 20:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.