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.
HostKeyentry for that file or noHostKeyentries at all (thus using the default)HostKeylines 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) whyHostKeyAlgorithms +ssh-rsahas to go before the other config files are included, since I thought "+" meant to add it to the end.Matchblock; see the manpage (2) for most config-items (HostKeyis 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.