让我们看一下使无密码 ssh 运行的“正常”步骤:
- 创建一个 ssh 密钥
id_rsa
,将其添加到~/.ssh
目录并执行chmod 0600
操作。 - 将添加
id_rsa.pub
到~/.ssh/authorized_keys
。确保文件也是0600
好吧,这应该足以使以下工作正常进行:
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
并且成功了。