Debian 12 / Ubuntu 22.04 开启 SSH 的 RSA Key 登录
source link: https://vpsxb.net/4661/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
本文将指导如何在 Debian 12 和 Ubuntu 22.04 开启 SSH 的 RSA Key 登录。自从 OpenSSH 8.3 开始,RSA Key 登录默认被禁用,并被认为不安全。所以从 Ubuntu 22.04 和 Debian 12 开始,如果某些古老的业务需要使用 RSA Key 登录,你需要手动开启 RSA Key 登录。
开启 RSA Key 登录
我们不需要修改 /etc/ssh/sshd_config
这个系统默认的 SSH 配置文件,只需要添加一个 /etc/ssh/sshd_config.d/enable_rsa_keys.conf
配置文件即可:
cat > /etc/ssh/sshd_config.d/enable_rsa_keys.conf << EOF
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
EOF
重启 SSH 服务
然后重启 SSH 服务即可:
systemctl status ssh
systemctl restart sshd
这两个服务在 Debian 12 下都是一样的:
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
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
我们可以看到 sshd 其实是 ssh 服务的别称:
root@debian ~ # cat /lib/systemd/system/ssh.service | grep Alias
Alias=sshd.service
此时您就可以使用 RSA Key 登录 SSH 了。
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK