使用 id_rsa 密钥的 ssh 身份验证不起作用

使用 id_rsa 密钥的 ssh 身份验证不起作用

Openssh 似乎找到了我的 id_rsa 密钥,但是随后:

debug2: we sent a publickey packet, wait for reply

它重新开始:

debug1: Authentications that can continue: publickey,password

并最终要求输入密码而不是使用我的公钥。

从日志中我真的看不出出了什么问题......

这是有关身份验证的输出:

debug2: key: /opt/redmine/.ssh/id_rsa (0x7fe9e43e2900),
debug2: key: /opt/redmine/.ssh/id_dsa ((nil)),
debug2: key: /opt/redmine/.ssh/id_ecdsa ((nil)),
debug2: key: /opt/redmine/.ssh/id_ed25519 ((nil)),
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /opt/redmine/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /opt/redmine/.ssh/id_dsa
debug3: no such identity: /opt/redmine/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /opt/redmine/.ssh/id_ecdsa
debug3: no such identity: /opt/redmine/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /opt/redmine/.ssh/id_ed25519
debug3: no such identity: /opt/redmine/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password

有人能指点一下哪里出了问题吗?

答案1

问题出在ssh服务器。授权密钥文件设置为,/opt/gitolite/.ssh/authorized_keys但文件包含客户端公钥的路径,而不是密钥本身。

要解决此问题,您需要将公钥原样复制到文件中,/opt/gitolite/.ssh/authorized_keys并删除文件中所有其他现有的不相关内容。请注意,此文件应由适当的用户拥有,并且权限位应为600

相关内容