【问题标题】:Matching key found, but still require password [preauth]找到匹配的密钥,但仍需要密码 [preauth]
【发布时间】:2014-10-14 19:57:03
【问题描述】:

我使用 SSH 连接到一台机器。没有密码访问,只有一个现有的 SSH 密钥有效。

我需要创建一个新密钥(production.key、production.key.pub),我这样做了,但没有选择密码:

cd /home
sudo ssh-keygen -t rsa

然后我像这样将公钥复制到机器上:

cat /home/production.key.pub | ssh -i /home/old_key user@<IP> "cat >> /root/.ssh/authorized_keys"

然后我尝试这样登录:

ssh -i /home/production.key user@<IP>

但我仍然收到密码提示。所以我在调试模式下再次尝试使用 sshd,得到了这个输出:

debug1: matching key found: file /root/.ssh/authorized_keys, line 2 RSA XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
debug1: restore_uid: 0/0
Postponed publickey for root from XX.XX.XX.XX port 60407 ssh2 [preauth]
debug1: userauth-request for user root service ssh-connection method password [preauth]

我做错了什么?为什么在提示“找到匹配的密钥”时仍然提示密码?我该如何解决这个问题?

【问题讨论】:

  • 我也有同样的问题。你找到解决办法了吗?

标签: ssh ssh-keys openssh


【解决方案1】:

我从 sshd 收到了相同的消息,并发现客户端实际上缺少私钥文件。只有公钥在那里。

【讨论】:

    【解决方案2】:

    我通过将私钥的权限从 600 更改为 644 来解决此问题:

     sudo chmod 644 /home/production.key
    

    【讨论】:

    • 644 因密钥文件权限错误而引发错误。 600 是正确的,但我仍然面临上面的原始问题。
    猜你喜欢
    • 1970-01-01
    • 2014-12-16
    • 2014-02-01
    • 2021-04-04
    • 2018-09-22
    • 1970-01-01
    • 2019-05-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多