Hi there, given the recent events, the NSA published an advisory recommending an immediate transition to post-quantum cryptography. Filippo wrote a very good breakdown of it, so go read his post for all the details: https://words.filippo.io/nsa-advisory/
The short version, reading between the lines as he does:
The NSA itself says the recent advances do not present an immediate and widespread threat, so no need to panic, but no reason to wait either.
OpenBSD has had mldsa44-ed25519 in OpenSSH for a while now (OpenSSH 10.6 and OpenBSD 8.0 already have it), and ssh-keygen -A already creates it as a default host key type. But in case you want to be sure and get rid of all the other algorithms, you should do something like this.
Keep one session open the whole time. If something breaks, you still have a way back in.
Run this on both the client and the server:
$ ssh -V
$ ssh -Q key | grep -i mldsa
If nothing shows up, your OpenSSH is too old. Update first.
$ ssh-keygen -t mldsa44-ed25519 -f ~/.ssh/id_mldsa44_ed25519
Copy the public key to the server (or use ssh-copy-id if you have it installed) and test it by itself:
$ cat ~/.ssh/id_mldsa44_ed25519.pub | ssh user@server 'cat >> ~/.ssh/authorized_keys'
$ ssh -o IdentitiesOnly=yes -i ~/.ssh/id_mldsa44_ed25519 user@server
If this logs you in, the new key works.
ssh-keygen(1) with -A only creates host keys that are missing, so we make this one by hand. Host keys need an empty passphrase.
$ doas ssh-keygen -t mldsa44-ed25519 -f /etc/ssh/ssh_host_mldsa44_ed25519_key -N ''
$ doas rm /etc/ssh/ssh_host_rsa_key* /etc/ssh/ssh_host_ed25519_key*
You probably already have this key if you are on -current or 8.0, so you can skip the first command.
Heads up: /etc/rc runs ssh-keygen -A at boot, so the old default host keys can come back after a reboot. That's fine, because sshd only uses the keys you list with HostKey.
Edit /etc/ssh/sshd_config, see sshd_config(5). The leading - removes algorithms from the default list:
HostKey /etc/ssh/ssh_host_mldsa44_ed25519_key
HostKeyAlgorithms -ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-rsa-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com
PubkeyAcceptedAlgorithms -ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-rsa-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com
This might be taken care of by the next sysmerge(8) you run, but if you want to be ahead of it, do it now.
Validate and reload. Your open session stays alive:
$ doas sshd -t && doas rcctl reload sshd
Then remove the old public keys from authorized_keys by hand and check what is left:
$ vi ~/.ssh/authorized_keys
$ ssh-keygen -l -f ~/.ssh/authorized_keys
The host key changed, so drop the old entry and accept the new one:
$ ssh-keygen -R server
$ ssh user@server
Now make it permanent and extra careful, in ~/.ssh/config, with the same removals as on the server, see ssh_config(5):
Host *
IdentityFile ~/.ssh/id_mldsa44_ed25519
HostKeyAlgorithms -ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-rsa-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com
PubkeyAcceptedAlgorithms -ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-rsa-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,ssh-ed25519,ssh-ed25519-cert-v01@openssh.com
Only when everything works, and after opening a fresh session to confirm, delete the old private keys:
$ rm ~/.ssh/id_rsa ~/.ssh/id_rsa.pub ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub
That's it. Remember that with Ed25519 and RSA removed from PubkeyAcceptedAlgorithms, every machine you connect to needs an OpenSSH that knows the new key type, or you lock yourself out. Test on one box before you do the whole fleet.