为什么我的SSH密钥不能连接到github? [英] Why doesn't my SSH key work for connecting to github?

查看:135
本文介绍了为什么我的SSH密钥不能连接到github?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我不是一个新手,我已经做了这么多次,但由于某种原因,今天它决定不工作。



我保留当尝试通过SSH连接到github或试图克隆repo时,甚至在重新创建ssh密钥并将其添加到密码后,获取 Permission denied(publickey)。 SSH密钥。



这是我今天试图做的十次 ,没有成功:


  1. 使用ssh-keygen创建密钥。

  2. 使用Gedit或Notepad ++打开〜/ .ssh / id_rsa.pub并复制内容。
  3. 转到github.com上的帐户设置

  4. 转到SSH密钥

  5. 单击添加密钥按钮。

  6. 给密钥一个标题

  7. 将密钥粘贴到密钥框中。 (输入我的github密码进行验证)。

现在,当我尝试执行 ssh github时。 com 它不会工作....世界上有什么?我现在只是太累了,或者我错过了什么?



以下是 ssh -vvv github.com

  OpenSSH_5.9p1,OpenSSL 1.0.0f 2012年1月4日
debug1:读取配置数据/ etc / ssh / ssh_config
debug2:ssh_connect:needpriv 0
debug1:连接到github.com [207.97.227.239]端口22.
debug1:建立连接。
debug3:错误的RSA1标识符
debug3:无法加载/home/trusktr/.ssh/id_rsa作为RSA1公钥
debug1:身份文件/home/trusktr/.ssh/ id_rsa类型1
debug1:标识文件/home/trusktr/.ssh/id_rsa-cert类型-1
debug1:标识文件/home/trusktr/.ssh/id_dsa类型-1
debug1 :身份文件/home/trusktr/.ssh/id_dsa-cert类型-1
debug1:身份文件/home/trusktr/.ssh/id_ecdsa类型-1
debug1:身份文件/ home / trusktr / .ssh / id_ecdsa-cert类型-1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.1p1 Debian-5github2
debug1:匹配:OpenSSH_5.1p1 Debian-5github2 pat OpenSSH *
debug1:为协议2.0启用兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_5.9
debug2:fd 3设置O_NONBLOCK
debug3:load_hostkeys:加载主机的条目github.com from file/home/trusktr/.ssh/known_hosts
debug3:load_hostkeys:在文件/home/trusktr/.ssh/known_hos中找到密钥类型RSA ts:16
debug3:load_hostkeys:加载1个键
debug3:order_hostkeyalgs:prefer hostkeyalgs:ssh-rsa-cert-v01 @ openssh.com,ssh-rsa-cert-v00 @ openssh.com,ssh -rsa
debug1:SSH2_MSG_KEXINIT发送
debug1:SSH2_MSG_KEXINIT收到
debug2:kex_parse_kexinit:ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group- exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2:kex_parse_kexinit:ssh-rsa-cert-v01 @ openssh.com,ssh -RSA-CERT-V00 @ openssh.com,SSH-RSA,ECDSA-SHA2-nistp256-CERT-V01 @ openssh.com,ECDSA-SHA2-nistp384-CERT-V01 @ openssh.com,ECDSA-SHA2-nistp521证书-v01 @ openssh.com,SSH-DSS-CERT-V01 @ openssh.com,SSH-DSS-CERT-V00 @ openssh.com,ECDSA-SHA2-nistp256,ECDSA-SHA2-nistp384,ECDSA-SHA2-nistp521,SSH -dss
debug2:kex_parse_kexinit:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc, arcfour,rijndael-cbc @ lysator.liu.se
de bug2:kex_parse_kexinit:aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc @ lysator.liu.se
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64 @ openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac -sha2-512-96,hmac-ripemd160,hmac-ripemd160 @ openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64 @ openssh.com,HMAC-sha2-256,HMAC-sha2-256-96,HMAC-sha2-512,HMAC-sha2-512-96,HMAC-RIPEMD160,HMAC-RIPEMD160 @ openssh.com,HMAC-SHA1-96, hmac-md5-96
debug2:kex_parse_kexinit:none,zlib @ openssh.com,zlib
debug2:kex_parse_kexinit:none,zlib @ openssh.com,zlib
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:first_kex_follows 0
debug2:kex_parse_kexinit:reserved 0
debug2:kex_parse_kexinit:diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange -sha1,的Diffie-Hellman-group14-SHA1,DIFF ie-hellman-group1-sha1
debug2:kex_parse_kexinit:ssh-rsa,ssh-dss
debug2:kex_parse_kexinit:aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256, arcfour,aes192-cbc,aes256-cbc,rijndael-cbc @ lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2:kex_parse_kexinit:aes128-cbc,3des-cbc,blowfish-cbc ,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc @ lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2:kex_parse_kexinit:hmac- md5,hmac-sha1,umac-64 @ openssh.com,hmac-ripemd160,hmac-ripemd160 @ openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:hmac-md5,hmac -sha1,umac-64 @ openssh.com,hmac-ripemd160,hmac-ripemd160 @ openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:none,zlib @ openssh.com
debug2:kex_parse_kexinit:none,zlib @ openssh.com
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:first_kex_follows 0
debug2:kex_parse_kexinit:保留0
debug2:mac_setup:找到hmac-md5
debug1:kex:server->客户端aes128 -ctr hmac-md5 none
debug2:mac_setup:找到hmac-md5
debug1:kex:客户端>服务器aes128-ctr hmac-md5无
debug1:SSH2_MSG_KEX_DH_GEX_REQUEST(1024 <1024 <8192)发送
debug1:期望SSH2_MSG_KEX_DH_GEX_GROUP
debug2:dh_gen_key:priv密钥比特集:122 / 256
debug2:位设置:510/1024
d ebug1:SSH2_MSG_KEX_DH_GEX_INIT发送
debug1:期望SSH2_MSG_KEX_DH_GEX_REPLY
debug1:服务器主机密钥:RSA 16:27:ac:a5:76: 28:2d:36:63:1b:56:4d:eb:df:a6:48
debug3:load_hostkeys:从文件/home/trusktr/.ssh/known_hosts加载主机github.com的条目
debug3:load_hostkeys:在文件中找到密钥类型RSA /home/trusktr/.ssh/known_hosts:16
debug3:load_hostkeys:加载1个键
debug3:load_hostkeys:加载主机的条目 207.97.227.239来自文件/home/trusktr/.ssh/known_hosts
debug3:load_hostkeys:在文件/ home / trusktr /中找到密钥类型RSA。 ssh / known_hosts:16
debug3:load_hostkeys:加载1个键
debug1:主机'github.com'是已知的,并且与RSA主机键匹配。
debug1:在/home/trusktr/.ssh/known_hosts:16
找到密钥debug2:位设置:497/1024
debug1:ssh_rsa_verify:签名正确
debug2:kex_derive_keys
debug2:set_newkeys:模式1
debug1:SSH2_MSG_NEWKEYS发送
debug1:期望SSH2_MSG_NEWKEYS
debug2:set_newkeys:模式0
debug1:SSH2_MSG_NEWKEYS收到
debug1:漫游不允许服务器
debug1:SSH2_MSG_SERVICE_REQUEST发送
debug2:service_accept:ssh-userauth
debug1:收到SSH2_MSG_SERVICE_ACCEPT
debug2:key:/home/trusktr/.ssh/id_rsa(0x14cce60 )
debug2:key:trusktr @ rocketship(0x14ce2b0)
debug2:key:/home/trusktr/.ssh/id_dsa((nil))
debug2:key:/ home / trusktr / .ssh / id_ecdsa((nil))
debug1:可继续的身份验证:publickey
debug3:重新开始,传递不同的列表publickey
debug3:首选publickey,keyboard-interactive,password
debug3:authmethod_lookup publickey
debug3:其余首选项:keyboard-int eractive,密码
debug3:authmethod_is_enabled publickey
debug1:下一个验证方法:publickey
debug1:提供RSA公钥:/home/trusktr/.ssh/id_rsa
debug3:send_pubkey_test
debug2:我们发送了一个publickey包,等待回复
debug1:可以继续的认证:publickey
debug1:提供RSA公钥:trusktr @ rocketship
debug3:send_pubkey_test
debug2:我们发送一个publickey包,等待回复
debug1:可以继续的认证:publickey
debug1:尝试私钥:/home/trusktr/.ssh/id_dsa
debug3:no这样的标识:/home/trusktr/.ssh/id_dsa
debug1:尝试私钥:/home/trusktr/.ssh/id_ecdsa
debug3:没有这样的标识:/home/trusktr/.ssh/id_ecdsa
debug2:我们没有发送数据包,禁用方法
debug1:没有更多的身份验证方法可以尝试。
权限被拒绝(publickey)。


解决方案



<$ p $ .github.com / win-set-up-git /rel =noreferrer> GitHub ssh setup
p> $ ssh -T git@github.com

一个href =https://stackoverflow.com/questions/9817976/pip-install-from-a-gitosis/9835653#9835653> ssh uri语法(也在这个答案)。



但你做到了:

  ssh github.com 

(无任何用户)。在这种情况下,ssh将恢复为 SCP语法,该语法依赖于 〜/ .ssh / config 文件,并带有 github.com 部分,以列出:




  • 用户

  • 主机名

  • (以及可选的公钥位置,但默认情况下为将尝试〜/ .ssh / id_rsa.pub

Note: I'm not a newb, and I've done this a gazillion times, but for some reason today it decided not to work.

I keep getting the Permission denied (publickey). error message when trying to connect to github via SSH or when trying to clone a repo, even after remaking the ssh key and adding it to "SSH Keys" in my account.

This is what I tried to do ten times today without success:

  1. make a key with ssh-keygen.
  2. open ~/.ssh/id_rsa.pub with Gedit or Notepad++ and copy the contents.
  3. Go to account settings on github.com
  4. Go to SSH Keys
  5. Click on the Add Key button.
  6. give the key a title
  7. paste the key into the key box.
  8. Save the key (enter my github password to verify).

And now, when I try doing ssh github.com it just won't work.... What in the world? Am I just too tired right now or am I missing something?

Here's the output from ssh -vvv github.com

OpenSSH_5.9p1, OpenSSL 1.0.0f 4 Jan 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/trusktr/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /home/trusktr/.ssh/id_rsa type 1
debug1: identity file /home/trusktr/.ssh/id_rsa-cert type -1
debug1: identity file /home/trusktr/.ssh/id_dsa type -1
debug1: identity file /home/trusktr/.ssh/id_dsa-cert type -1
debug1: identity file /home/trusktr/.ssh/id_ecdsa type -1
debug1: identity file /home/trusktr/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2
debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "github.com" from file "/home/trusktr/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa-cert-v01@openssh.com,ssh-rsa-cert-v00@openssh.com,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-dss-cert-v01@openssh.com,ssh-dss-cert-v00@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 122/256
debug2: bits set: 510/1024
d    ebug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48
debug3: load_hostkeys: loading entries for host "github.com" from file "/home/trusktr/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "207.97.227.239" from file "/home/trusktr/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/trusktr/.ssh/known_hosts:16
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/trusktr/.ssh/known_hosts:16
debug2: bits set: 497/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /home/trusktr/.ssh/id_rsa (0x14cce60)
debug2: key: trusktr@rocketship (0x14ce2b0)
debug2: key: /home/trusktr/.ssh/id_dsa ((nil))
debug2: key: /home/trusktr/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred 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: /home/trusktr/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: trusktr@rocketship
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/trusktr/.ssh/id_dsa
debug3: no such identity: /home/trusktr/.ssh/id_dsa
debug1: Trying private key: /home/trusktr/.ssh/id_ecdsa
debug3: no such identity: /home/trusktr/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

解决方案

The GitHub ssh setup mentions testing your GitHub connection with:

$ ssh -T git@github.com

That follow the ssh uri syntax (also illustrated in "this answer").

But you did:

ssh github.com

(without any user). In that case, ssh reverts to the SCP syntax, which relies on a ~/.ssh/config file, with a section "github.com", to list:

  • the user
  • the hostname
  • (and optionally the public key location, but by default it will try ~/.ssh/id_rsa.pub)

这篇关于为什么我的SSH密钥不能连接到github?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆