【问题标题】:ssh connection using RSA key keep asking password [closed]使用RSA密钥的ssh连接不断询问密码[关闭]
【发布时间】:2010-08-30 23:01:39
【问题描述】:

我正在尝试使用 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

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

【问题讨论】:

    标签: ssh solaris rsa


    【解决方案1】:
    chmod 744 ~/.ssh/authorized_keys
    

    为我工作。

    【讨论】:

    • "644" 更好...不需要执行。而且,.ssh 目录本身必须由“700”保护。但是 +1 为我指明了正确的方向
    【解决方案2】:

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

    【讨论】:

      【解决方案3】:

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

      【讨论】:

      • 感谢您提供此信息。我没有 root 访问权限来调查 Sun_SSH 的配置,但这肯定是问题所在。我会尝试让系统管理员参与进来。
      • /etc/ssh/ssd_config 应该是 /etc/ssh/sshd_config(或者可能是 /etc/ssh/ssh_config
      【解决方案4】:

      试一试

      chmod -R 600 ~/.ssh/

      可能是组/全局读取权限导致了问题。

      【讨论】:

      • 我试过了,但没有帮助。无论如何感谢您的尝试。
      • 这对我有帮助,同时将正确的 id_rsa 和 id_rsa.pub 文件复制到 ~/.ssh/ 文件夹中
      【解决方案5】:

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

      【讨论】:

      • 好的,谢谢 Olivier,很遗憾我无法再访问这些机器,所以我无法验证是否是这种情况。但如果它再次发生在我身上,我会检查这个;o)