我有一个关于 ssh 公钥身份验证的问题。我在 RHEL 9 机器上生成了一个密钥对(受密码保护),如下所示:
ssh-keygen -f .ssh/key2
然后,我将公钥复制到远程主机上:
ssh-copy-id -i .ssh/key2.pub operator1@servera
现在,当我尝试连接时,仍然会询问密钥密码:
ssh -i .ssh/key2 operator1@servera
在执行过程中添加 -v 选项表明服务器接受了密钥:
No Kerberos credentials available (default cache: KCM:)
debug1: No credentials were supplied, or the credentials were unavailable or inaccessible
No Kerberos credentials available (default cache: KCM:)
debug1: Next authentication method: publickey
debug1: Offering public key: .ssh/key2 RSA SHA256:wzFYOSGEvzLSjgKe5EGlKXXuaWmFmG8E6gfxs2KG6Pg explicit
debug1: Server accepts key: .ssh/key2 RSA SHA256:wzFYOSGEvzLSjgKe5EGlKXXuaWmFmG8E6gfxs2KG6Pg explicit
那么为什么要求我输入密码呢?旁注:我已经授予 .ssh 文件夹权限:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/key2