简体   繁体   English

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

[英]Can't connect to github via ssh; Permission denied (public key)

I'm trying to logon to github via ssh but it fails. 我正在尝试通过ssh登录到github,但是失败。 I've checked the github troubleshooting page to no avail. 我检查了github故障排除页面无济于事。 I've followed the guide on how to connect via ssh step by step on two separate computers. 我已按照指南逐步指导如何在两台单独的计算机上通过ssh进行连接。 I've tried specifying the path to id_rsa but it gives the same response. 我试过指定id_rsa的路径,但给出的响应相同。 The output I receive is the following: 我收到的输出如下:

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).

On the other computer which is a mac it also said key_load_public:No such file or directory after each identity file check. 在另一台是Mac的计算机上,它也表示key_load_public:No such file or directory在每次标识文件检查后都key_load_public:No such file or directory So perhaps ssh is not completely set up on my computers. 因此,也许ssh尚未完全在我的计算机上设置。 What is the problem? 问题是什么?


Simply follow those steps and you will set up your ssh key in no time: 只需按照以下步骤操作,您将立即设置ssh密钥:

  • Generate a new ssh key (or skip this step if you already have a key) 生成一个新的ssh密钥(如果已经有了密钥,则跳过此步骤)
    ssh-keygen -t rsa -C "your@email"

  • Once you have your key set in home/.ssh directory (or Users/<your user>.ssh under windows), open it and copy the content 将密钥设置到home/.ssh目录(或Windows下的Users/<your user>.ssh )后,将其打开并复制内容

In order to be on the safe side add the new keys to your ssh agent. 为了安全起见,将新密钥添加到ssh代理。

ssh-add ~/.ssh/id_rsa

How to add ssh key to github account? 如何将ssh密钥添加到github帐户?

  • Login to github account 登录到github帐户
  • Click on the rancher on the top right (Settings) 单击右上角的牧场主(设置)
    github帐户settigns
  • Click on the SSH keys 单击SSH keys
    ssh密钥部分
  • Click on the Add ssh key 单击Add ssh key
    添加SSH密钥
  • Paste your key and save 粘贴密钥并保存

And you all set to go :-) 你们所有人都去了:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM