GIT 的Permission denied, Authenticated can't be established的问题

今天准备学习一下RxJava的时候,git clone的时候遇到如下的问题:

darcy@darcy-pc:~/IdeaProjects$ git clone git@github.com:ReactiveX/RxJava.git
正克隆到 'RxJava'...
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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


# darcy @ darcy-pc in /etc [15:00:38] C:128

$ sudo git clone git@github.com:ReactiveX/RxJava.git

[sudo] darcy 的密码: 

正克隆到 'RxJava'...

The authenticity of host 'github.com (192.30.253.112)' can't be established.

RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.

Permission denied (publickey).

fatal: Could not read from remote repository.



Please make sure you have the correct access rights

and the repository exists.

然后又把.ssh删除了重新使用ssh-keygen生成了一遍,公钥添加到github仍然有问题,如下:


# darcy @ darcy-pc in /etc [15:01:09] C:128

$ ssh git@github.com

sign_and_send_pubkey: signing failed: agent refused operation

Permission denied (publickey).

然后查看了一下,参考了解决方案,如下:

首先

清除所有的key-pair
ssh-add -D
rm -r ~/.ssh
删除你在github中的public-key


# darcy @ darcy-pc in ~ [15:03:29] 

$ ssh-add -D

All identities removed.



# darcy @ darcy-pc in ~ [15:03:47] 

$ rm -rf ~/.ssh*

然后重新生成密钥:


# darcy @ darcy-pc in ~ [15:04:11] 

$ ssh-keygen -t rsa -C "YourGithubAccount@gmail.com"

Generating public/private rsa key pair.

Enter file in which to save the key (/home/darcy/.ssh/id_rsa): 

Created directory '/home/darcy/.ssh'.

Enter passphrase (empty for no passphrase): 

Enter same passphrase again: 

Your identification has been saved in /home/darcy/.ssh/id_rsa.

Your public key has been saved in /home/darcy/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxx@gmail.com

The key's randomart image is:

+---[RSA 2048]----+

xxxxxxx

xxxxx

+----[SHA256]-----+

修改一下.ssh目录的权限,把公钥复制到自己的github帐号的SSH密钥那里去;


# darcy @ darcy-pc in ~ [15:06:11] C:1

$ chmod 744 .ssh    

测试连通性,还特么不行。


# darcy @ darcy-pc in ~/.ssh [15:07:45] 

$ ssh -T git@github.com

The authenticity of host 'github.com (192.30.253.112)' can't be established.

RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.

sign_and_send_pubkey: signing failed: agent refused operation

Permission denied (publickey).

ok,往下,看到github的help;


# darcy @ darcy-pc in ~/.ssh [15:09:36] C:255

$ ssh -vT git@github.com

OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016

debug1: Reading configuration data /etc/ssh/ssh_config

xxxxxx

xxxxxx

debug1: Trying private key: /home/darcy/.ssh/id_ed25519

debug1: No more authentication methods to try.

Permission denied (publickey).



# darcy @ darcy-pc in ~/.ssh [15:11:17] C:255

$ eval "$(ssh-agent -s)"

Agent pid 14319

官方说说明如下:

You should be able to fix this error by loading your keys into your SSH agent with ssh-add


# darcy @ darcy-pc in ~/.ssh [15:12:45] 

$ ssh-add

Identity added: /home/darcy/.ssh/id_rsa (/home/darcy/.ssh/id_rsa)

再次测试,ok.


# darcy @ darcy-pc in ~/.ssh [15:13:04] 

$ ssh git@github.com                        

PTY allocation request failed on channel 0

Hi XXX! You've successfully authenticated, but GitHub does not provide shell access.

Connection to github.com closed.

去down RxJava



$ git clone git@github.com:ReactiveX/RxJava.git     

正克隆到 'RxJava'...

remote: Counting objects: 85770, done.

remote: Compressing objects: 100% (77/77), done.

接收对象中:   2% (1991/85770), 428.01 KiB | 5.00 KiB/s

ref site:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值