我正在尝试重新创建 ssh-server 主机密钥。
我至少有两种方法可以做到这一点:
使用 dpkg-reconfigure
dpkg-reconfigure openssh-server
Run Code Online (Sandbox Code Playgroud)
这工作正常,但我不能给出密钥长度。例如,我想要 4096 作为 RSA 密钥。
使用 ssh-keygen 手动
sudo ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N 'myverylongpasswordhere' -b 4096 -t rsa
Run Code Online (Sandbox Code Playgroud)
这会重新创建密钥,但是在重新启动服务器后,我收到以下错误消息:
could not load host key: /etc/ssh/ssh_host_rsa_key
Run Code Online (Sandbox Code Playgroud)
所以我检查了 sshd_config 文件中的内容:
HostKey /etc/ssh/ssh_host_rsa_key
Run Code Online (Sandbox Code Playgroud)
完美匹配。所以,我检查了我所有钥匙的所有者和权利
-rw------- 1 root root 3326 Mär 24 08:57 ssh_host_rsa_key
Run Code Online (Sandbox Code Playgroud)
当我删除所有密钥并使用 重新创建它们时dpkg-reconfigure openssh-server
,密钥更小并且具有与上述相同的文件权限。
问题:如何将dpkg-reconfigure
keylengh 4096 用于 RSA?