SSH连接使用RSA密钥仍然需要密码

3

我正在尝试设置使用RSA密钥无需密码连接多台服务器的SSH连接。这对大多数服务器有效,但有一台服务器出现了问题。

过去我遇到的最常见的问题是远程主机上的.ssh或authorized_keys权限问题,但这里看起来已经正确配置好了,如下所示:

drwx------  ~/.ssh
-rw-r--r--  ~/.ssh/authorized_keys

以下是连接此服务器时使用ssh -v命令的输出结果(我只更改了主机名和IP):

Sun_SSH_1.1.3, SSH protocols 1.5/2.0, OpenSSL 0x0090704f
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Rhosts Authentication disabled, originating port will not be trusted.
debug1: ssh_connect: needpriv 0
debug1: Connecting to myhost.mydomain.com [123.123.123.123] port 22.
debug1: Connection established.
debug1: identity file /export/home/webdev1/.ssh/identity type -1
debug1: identity file /export/home/webdev1/.ssh/id_rsa type 1
debug1: identity file /export/home/webdev1/.ssh/id_dsa type -1
debug1: Remote protocol version 1.5, remote software version 1.2.31
debug1: match: 1.2.31 pat 1.2.1*,1.2.2*,1.2.3*
debug1: Local version string SSH-1.5-Sun_SSH_1.1.3
debug1: Waiting for server public key.
debug1: Received server public key (768 bits) and host key (1024 bits).
debug1: Host 'myhost.mydomain.com' is known and matches the RSA1 host key.
debug1: Found key in /export/home/webdev1/.ssh/known_hosts:6
debug1: Encryption type: 3des
debug1: Sent encrypted session key.
debug1: cipher_init: set keylen (16 -> 32)
debug1: cipher_init: set keylen (16 -> 32)
debug1: Installing crc compensation attack detector.
debug1: Received encrypted confirmation.
debug1: Doing password authentication.

我怀疑这可能是由于SSH版本引起的。另一个正常工作的服务器给了我以下输出(远程协议版本为2.0而不是1.5):

debug1: Remote protocol version 2.0, remote software version Sun_SSH_1.1.3
debug1: match: Sun_SSH_1.1.3 pat Sun_SSH_1.1.*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-Sun_SSH_1.1.3

有什么线索吗? 谢谢你的帮助。

5个回答

3
chmod 744 ~/.ssh/authorized_keys

对我来说可行。


4
"644"更好...无需执行。另外,".ssh"目录本身必须通过"700"进行保护。但是因为你指导了我正确的方向,所以加个赞。 - Jan Galinski

2

确保您的主目录(/export/home/webdev1)也拥有700权限。


1
也许您的用户在Unix系统上被锁定了。如果您通常使用自己的帐户登录,然后“成为”功能用户,如果该用户启用了“密码登录”功能但您没有使用它,则可能会被锁定(例如密码过期)。 但是,即使它被锁定,也不会阻止您使用“be”命令进行sudo,但它肯定会阻止任何ssh登录,即使密钥是可信任的。

好的,谢谢Olivier。不幸的是,我现在无法访问这些机器,所以无法验证是否是这种情况。但如果再次发生,我会检查一下;o) - Damien

1

试试这个

chmod -R 600 ~/.ssh/

也许是组/全局读取权限引起的问题。


我尝试了,但那并没有帮助。无论如何,还是谢谢你的尝试。 - Damien
这对我很有帮助,还有将正确的id_rsa和id_rsa.pub文件复制到~/.ssh/文件夹中。 - despina

1
服务器可能被配置为拒绝基于公钥和无密码的身份验证。我不知道Sun_SSH,但在OpenSSH(Linux/*BSD系统上最常见的SSH实现),这是通过更改/etc/ssh/sshd_config中的一些设置来实现的(选项RSAAuthentication用于v1协议,PubkeyAuthentication用于v2)。

谢谢提供这个信息。我没有root权限去调查Sun_SSH的配置,但这肯定是问题所在。我会尝试联系系统管理员来解决。 - Damien
/etc/ssh/ssd_config 应该是 /etc/ssh/sshd_config(或者也许是 /etc/ssh/ssh_config)。 - Doug Molineux

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接