您当前的位置: 首页 >  git

qq_34412985

暂无认证

  • 0浏览

    0关注

    1061博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

git 中github clone "Permission denied (publickey). fatal: Could not read from remote repository."

qq_34412985 发布时间:2019-12-06 15:26:15 ,浏览量:0

第一次使用然后,,出现上述问题

解决办法均来自互联网:

设置Git的user name和email

git config –global user.name “yourname” git config –global user.email “youremail” 生成SSH密钥

查看是否已经有了ssh密钥:cd ~/.ssh 如果没有密钥则不会有此文件夹,有则备份删除 生存密钥: ssh-keygen -t rsa -C “haiyan.xu.vip@gmail.com” 按3个回车,密码为空。 Your identification has been saved in /home/tekkub/.ssh/id_rsa. Your public key has been saved in /home/tekkub/.ssh/id_rsa.pub. The key fingerprint is: ……………… 最后得到了两个文件:id_rsa和id_rsa.pub 添加密钥到ssh:ssh-add 文件名,需要之前输入密码.

在github上添加ssh密钥,这要添加的是“id_rsa.pub”里面的公钥。 打开https://github.com/,在设置中添加密钥

测试:ssh git@github.com The authenticity of host ‘github.com (207.97.227.239)’ can’t be established. RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added ‘github.com,207.97.227.239′ (RSA) to the list of known hosts. ERROR: Hi tekkub! You’ve successfully authenticated, but GitHub does not provide shell access Connection to github.com closed.

解决办法:

1.ssh -v git@github.com

测试ssh连接是否成功,如LZ显示如下:

$ ssh -v git@github.com

OpenSSH_7.3p1, OpenSSL 1.0.2j 26 Sep 2016

[plain] view plain copy debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to github.com [192.30.253.113] port 22. debug1: Connection established. debug1: identity file /c/Users/Administrator/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/Administrator/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.3 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: algorithm: curve25519-sha256@libssh.org debug1: kex: host key algorithm: ssh-rsa debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: compression: 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/Administrator/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /c/Users/Administrator/.ssh/id_rsa debug1: Authentications that can continue: publickey debug1: Trying private key: /c/Users/Administrator/.ssh/id_dsa debug1: Trying private key: /c/Users/Administrator/.ssh/id_ecdsa debug1: Trying private key: /c/Users/Administrator/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey).

    ssh-agent -s

[plain] view plain copy $ ssh-agent -s SSH_AUTH_SOCK=/tmp/ssh-GTpABX1a05qH/agent.404; export SSH_AUTH_SOCK; SSH_AGENT_PID=13144; export SSH_AGENT_PID; echo Agent pid 13144;

    ssh-add ~/.ssh/id_rsa

[plain] view plain copy $ ssh-add ~/.ssh/id_rsa Could not open a connection to your authentication agent. LZ这一步报错了,继续执行:eval ssh-agent -s 无错请忽略以下步骤

[plain] view plain copy $ eval ssh-agent -s Agent pid 24460 再次执行ssh-add ~/.ssh/id_rsa

[plain] view plain copy $ ssh-add ~/.ssh/id_rsa Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa)

4.将客户端生成的key添加到github账户

首先使用 clip < ~/.ssh/id_rsa.pub 或者文本编辑拷贝id_rsa.pub文本内容

到github右上角账户管理-Setting下面找到左侧“SSH and

GPG keys”菜单,接着点击“Add SSH key”,在”title”栏输入一个自己喜欢的标题,“key”栏中粘贴刚刚复制的公钥内容,最后点击“Add key”按钮。

5.最后一步,验证key

[plain] view plain copy $ ssh -T git@github.com Hi wuwei! You’ve successfully authenticated, but GitHub does not provide shell access.

接下来就可以愉快的去clone github上优秀的项目了。

当采用第二种办法时遇到没有文件夹的时候,我们就应该采用第一种办法建立文件夹

关注
打赏
1653291990
查看更多评论
立即登录/注册

微信扫码登录

0.0394s