无法通过ssh连接到github;权限被拒绝(公钥)

时间:2015-11-26 08:34:47

标签: git macos ubuntu github ssh

我正在尝试通过ssh登录到github,但它失败了。我检查了github故障排除页面无济于事。我已经按照指南介绍了如何通过ssh在两台独立的计算机上逐步连接。我已经尝试指定id_rsa的路径,但它给出了相同的响应。我收到的输出如下:

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.252.130] port 22.
debug1: Connection established.
debug1: identity file /home/disid/.ssh/id_rsa type 1
debug1: identity file /home/disid/.ssh/id_rsa-cert type -1
debug1: identity file /home/disid/.ssh/id_dsa type -1
debug1: identity file /home/disid/.ssh/id_dsa-cert type -1
debug1: identity file /home/disid/.ssh/id_ecdsa type -1
debug1: identity file /home/disid/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/disid/.ssh/id_ed25519 type -1
debug1: identity file /home/disid/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
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_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA **:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/disid/.ssh/known_hosts:1
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: /home/disid/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/disid/.ssh/id_dsa
debug1: Trying private key: /home/disid/.ssh/id_ecdsa
debug1: Trying private key: /home/disid/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

在另一台Mac计算机上,每个身份文件检查后也会说key_load_public:No such file or directory。所以也许ssh并没有完全在我的电脑上设置。有什么问题?

1 个答案:

答案 0 :(得分:0)

只需按照这些步骤操作即可立即设置ssh密钥:

  • 生成新的ssh密钥(如果已有密钥,则跳过此步骤)
    ssh-keygen -t rsa -C "your@email"

  • 将密钥设置在home/.ssh目录(或Windows下的Users/<your user>.ssh)后,打开它并复制内容

为了安全起见,请将新密钥添加到ssh代理中。

ssh-add ~/.ssh/id_rsa

如何将ssh密钥添加到github帐户?

  • 登录github帐户
  • 点击右上角的牧场主(设置)
    github account settigns
  • 点击SSH keys
    ssh key section
  • 点击Add ssh key
    Add ssh key
  • 粘贴您的密钥并保存

你们都准备出发了: - )

相关问题