Debian 12 / Ubuntu 24.04 开启 SSH 的 RSA Key 登录
侧边栏壁纸
  • 累计撰写 635 篇文章
  • 累计收到 0 条评论

Debian 12 / Ubuntu 24.04 开启 SSH 的 RSA Key 登录

加速器之家
2024-08-12 / 0 评论 / 4 阅读 / 正在检测是否收录...

本文将指导如何在 Debian 12 和 Ubuntu 24.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 了。

0

评论

博主关闭了当前页面的评论