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

linux admin 11个月前 (06-24) 545次浏览 0个评论
本文将指导如何在 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 了。

Debian 12 / Ubuntu 22.04 开启 SSH 的 RSA Key 登录
无责任编辑
Showfom
发布时间
Jun 10th, 2023
版权协议

VPS小白 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Debian 12 / Ubuntu 22.04 开启 SSH 的 RSA Key 登录
喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址