This article will guide you on how to enable RSA Key login for SSH in Debian 12 and Ubuntu 22.04.

Since OpenSSH 8.3, RSA Key login has been disabled by default and is considered insecure.

So starting with Ubuntu 22.04 and Debian 12, if you need to use RSA Key login, you will need to enable it manually.

Enabling RSA Key login

Instead of modifying /etc/ssh/sshd_config, which is the default SSH configuration file, we just need to add a /etc/ssh/sshd_config.d/enable_rsa_keys.conf configuration file:

1
2
3
4
cat > /etc/ssh/sshd_config.d/enable_rsa_keys.conf << EOF
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
EOF

Restart the SSH service

Then simply restart the SSH service.

1
systemctl status ssh

or

1
systemctl restart sshd

Both of these services are the same under Debian 12.

1
2
3
4
root@debian ~ # systemctl status ssh.service
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-06-09 16:54:43 UTC; 15min ago
1
2
3
4
root@debian ~ # systemctl status sshd
● ssh.service - OpenBSD Secure Shell server
     Loaded: loaded (/lib/systemd/system/ssh.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-06-09 16:54:43 UTC; 15min ago

We can see that sshd is actually an alias for the ssh service:

1
2
root@debian ~ # cat /lib/systemd/system/ssh.service | grep Alias
Alias=sshd.service

At this point you will be able to log in to SSH using the RSA Key.