git权限被拒绝(公钥)

等待鸭子

我想为git设置ssh时遇到了一些问题。这是我收到的错误消息。

mbp-op-159:.ssh weiting.cheng$ ssh -vT [email protected]
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to github.com [192.168.1.1] port 22.
debug1: Connection established.
debug1: identity file /Users/c/.ssh/id_rsa type 1
debug1: identity file /Users/c/.ssh/id_rsa-cert type -1
debug1: identity file /Users/c/.ssh/id_dsa type -1
debug1: identity file /Users/c/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: sending SSH2_MSG_KEXDH_INIT
debug1: expecting SSH2_MSG_KEXDH_REPLY
debug1: Server host key: RSA     16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/c/.ssh/known_hosts:2
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

我按照git hub文档上的说明进行操作,但是他们没有提到我的问题。

我有私钥

debug1: identity file /Users/c/.ssh/id_rsa type 1

我还将密钥添加到我的git hub帐户

git成功获取我的私钥

debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/c/.ssh/id_rsa

但是由于未知原因,git继续运行id_dsa,但我没有生成它。

debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/c/.ssh/id_dsa
debug1: No more authentication methods to try.

然后我被拒绝了。

有人建议解决这个问题吗?

缺口

您的密码无效。我建议您完全重新开始,因此继续删除~/.ssh/文件夹中的所有内容(除外known_hosts,您可能应该保留它)。然后运行:

ssh-keygen -t rsa -b 4096 -C "[email protected]"

使用与您的GitHub帐户关联的电子邮件地址。确保将密钥保存在正确的用户文件夹中。您的情况下,密钥应另存为/Users/c/.ssh/id_rsa

最后,将的内容复制~/.ssh/id_rsa.pub到剪贴板。转到GitHub设置,单击“ SSH密钥”选项卡,然后添加刚刚复制的密钥。

我相信您已经看过了,但是这里是更详细的演练

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章