问题描述
git clone 和 git push origin master 错误
错误信息:
black-hole@IMP:~/test$ git clone git@github.com:BlackHole1/WebRtcXSS.git正克隆到 ’WebRtcXSS’...Agent admitted failure to sign using the key.Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.black-hole@IMP:~/test$ sudo git push origin master[sudo] password for black-hole: ssh: connect to host github.com port 22: Connection refusedfatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.black-hole@IMP:~/test$
尝试的解决方案:sudo vim ~/.ssh/config:
Host github.comUser 158099591@qq.comHostname ssh.github.comPreferredAuthentications publickeyIdentityFile ~/.ssh/id_rsaPort 443
已经在github上添加了ssh卸载重装了ssh重新编译了git最新版本(今天早上2点down的)
系统信息:
Linux version 3.16.0-4-686-pae (debian-kernel@lists.debian.org) (gcc version 4.8.4 (Debian 4.8.4-1) ) #1 SMP Debian 3.16.36-1 (2016-07-04)No LSB modules are available.Distributor ID: DebianDescription: Debian GNU/Linux 8.5 (jessie)Release: 8.5Codename: jessie
其他信息
black-hole@IMP:~/deb$ git --versiongit version 2.9.0.GITblack-hole@IMP:~/deb$ ssh -VOpenSSH_6.7p1 Debian-5+deb8u2, OpenSSL 1.0.1t 3 May 2016
难道是系统问题么?
Email:158blackhole@gmail.com
问题已解决:我删除github上面的ssh key。重新在debian里生成一个key,覆盖之前的key文件,然后再修改~/.ssh/config。就行了。参考链接:https://www.chenyudong.com/archives/ssh-using-private-public-key-no-password.html http://www.01happy.com/ssh-unprotected-private-key-file/ http://blog.sina.com.cn/s/blog_6e3583590101dvlx.html
折腾了一天终于搞定了=-=,不过我之前也有这么干,但是没成功。今天居然成功了。没办法有些时候还真的要拼RP、YZ
问题解答
回答1:你 github 上的 ssh public key 可能不对应,检查下
回答2:回答一下 @hsfzxjy 提出的ssh -vT git@github.com
Permission denied (publickey).black-hole@IMP:~/deb$ ssh -vT git@github.comOpenSSH_6.7p1 Debian-5+deb8u2, OpenSSL 1.0.1t 3 May 2016debug1: Reading configuration data /home/black-hole/.ssh/configdebug1: /home/black-hole/.ssh/config line 1: Applying options for github.comdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Hostname has changed; re-reading configurationdebug1: Reading configuration data /home/black-hole/.ssh/configdebug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Connecting to ssh.github.com [192.30.253.123] port 443.debug1: Connection established.debug1: identity file /home/black-hole/.ssh/id_rsa type 1debug1: key_load_public: No such file or directorydebug1: identity file /home/black-hole/.ssh/id_rsa-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.7p1 Debian-5+deb8u2debug1: Remote protocol version 2.0, remote software version libssh-0.7.0debug1: no match: libssh-0.7.0debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: server->client aes128-ctr hmac-sha2-256 nonedebug1: kex: client->server aes128-ctr hmac-sha2-256 nonedebug1: sending SSH2_MSG_KEX_ECDH_INITdebug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48debug1: Host ’[ssh.github.com]:443’ is known and matches the RSA host key.debug1: Found key in /home/black-hole/.ssh/known_hosts:1debug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: SSH2_MSG_SERVICE_REQUEST sentdebug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickeydebug1: Next authentication method: publickeydebug1: Offering RSA public key: /home/black-hole/.ssh/id_rsadebug1: Server accepts key: pkalg ssh-rsa blen 279Agent admitted failure to sign using the key.debug1: No more authentication methods to try.Permission denied (publickey).