即使采取正常步骤,无密码 ssh 仍不起作用

即使采取正常步骤,无密码 ssh 仍不起作用

让我们看一下使无密码 ssh 运行的“正常”步骤:

  1. 创建一个 ssh 密钥id_rsa,将其添加到~/.ssh目录并执行chmod 0600操作。
  2. 将添加id_rsa.pub~/.ssh/authorized_keys。确保文件也是0600
  3. 好吧,这应该足以使以下工作正常进行:

    ssh 本地主机

    ssh(主机名).local(因为在 Mac 上)

然而我却得到了可怕的

Password:

因此重新运行它-vv

 ssh -vv myhost.local

以下是更有趣的输出部分:

debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/steve/.ssh/id_rsa
debug2: we sent a publickey packet, wait for reply
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug2: input_userauth_pk_ok: fp SHA256:lwo/CxupCjhYOL8I9MuCD8tQTbb2uIDHDVuTBb/npJk
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /Users/steve/.ssh/id_dsa
debug1: Trying private key: /Users/steve/.ssh/id_ecdsa
debug1: Trying private key: /Users/steve/.ssh/id_ed25519
debug2: we did not send a packet, disable method
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1

特别注意做过捡起

 Offering RSA public key: /Users/steve/.ssh/id_rsa

这就是我想要的但是..那么为什么它没有被接受呢?我还应该在这里寻找什么?

答案1

id_rsa损坏。我以前用过它:所以不确定是怎么发生的。

通过生成新密钥ssh-keygen -t rsa -i ~/.ssh/id_rsa_new然后运行来验证这一点

     ssh -i ~/.ssh/id_rsa_new

并且成功了。

相关内容