Permission denied (publickey)

一、问题描述
在执行 $ ssh -vT git@github.com 时候发生 permission denied(publickey)
同样的问题出现在其他的命令中。

/************************错误一********************************/
$  ssh -vT git@github.com
OpenSSH_7.1p2, OpenSSL 1.0.2h  3 May 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: Connection established.
debug1: identity file /c/Users/xiaoliu/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/xiaoliu/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
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: /c/Users/xiaoliu/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/xiaoliu/.ssh/id_dsa
debug1: Trying private key: /c/Users/xiaoliu/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/xiaoliu/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

/*************************错误二******************************/
$ git clone git@github.com:yfzyn/StudyHubTest
Cloning into 'StudyHubTest'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.


二、调查
google了很多,最后根据github官网中的提供help的,终于一步一步解决了。
附GitHubHelp中的Error:Permission denied(publickey)的地址:
https://help.github.com/articles/error-permission-denied-publickey/

参考GitHubHelp中的内容,发现和Verify the public key is attached your account
描述的有出入。

/********************************再现********************************/
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ eval $(ssh-agent -s)
Agent pid 9296

xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ ssh-add -l
The agent has no identities.

三、解决
问题就在最后,现在就需要添加indentities,在添加identities之前,要确保本地的用户目录下
key已经生成。
生成方法:TODO
以及agent开启
$ eval `ssh-agent -s`

前面都没有问题后,开始最后的步骤:
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/xiaoliu/.ssh/id_rsa (/c/Users/xiaoliu/.ssh/id_rsa)
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ ssh-add ~/.ssh/github_rsa
Identity added: /c/Users/xiaoliu/.ssh/github_rsa (/c/Users/xiaoliu/.ssh/github_rsa)
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ ssh-add -l
2048 SHA256:UddFzmdP+tNyJ1+KQGucGhP2eCNxqNmV3mY/7GMwxTg /c/Users/xiaoliu/.ssh/id_rsa (RSA)
2048 SHA256:NI04iDjgB3nq2NDfraCz/Ej/SJz5SGzWn33/56VuC+o /c/Users/xiaoliu/.ssh/github_rsa (RSA)

现在就成功了。

/**********************成功一******************************************/
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ ssh -vT git@github.com
OpenSSH_7.1p2, OpenSSL 1.0.2h  3 May 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [192.30.253.112] port 22.
debug1: Connection established.
debug1: identity file /c/Users/xiaoliu/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /c/Users/xiaoliu/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version libssh-0.7.0
debug1: no match: libssh-0.7.0
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /c/Users/xiaoliu/.ssh/known_hosts:1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
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: /c/Users/xiaoliu/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Offering RSA public key: /c/Users/xiaoliu/.ssh/github_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.253.112]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
Hi yfzyn! You've successfully authenticated, but GitHub does not provide shell access.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3428, received 1804 bytes, in 0.6 seconds
Bytes per second: sent 5628.3, received 2961.9
debug1: Exit status 1

/**********************成功二******************************************/
xiaoliu@XIAOLIU2 MINGW64 /c/60073226/02_Personal/04_Workspaces/01_eclipse (master)
$ git clone git@github.com:yfzyn/StudyHubTest.git
Cloning into 'StudyHubTest'...
remote: Counting objects: 21, done.
remote: Total 21 (delta 0), reused 0 (delta 0), pack-reused 21
Receiving objects: 100% (21/21), 219.65 KiB | 84.00 KiB/s, done.
Checking connectivity... done.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值