2015-11-11 239 views
2

我遇到了一些问题,当我想设置ssh到我的git。这是我得到的错误消息。git权限被拒绝(publickey)

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的枢纽帐户

混帐成功拿到我的私钥

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. 

然后我得到了权限被拒绝。

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

+0

您是否将您的**公钥**或您的**私钥**添加到GitHub中?这个非常重要;如果你已经完成了后者,则过期/销毁该密钥并重新生成一个新的公私密钥对并使用公钥。 – Makoto

回答

1

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

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

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

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

我相信你已经看过这个了,但是这里有一个more detailed walkthrough

相关问题