首页 > 代码库 > SSH方式登录github出现Permission denied (publickey)
SSH方式登录github出现Permission denied (publickey)
今天在公司上传了代码,回到家pull,结果竟然出现了“Permission denied (publickey)“这种东西。第一反应是key不对,可是上次明明用key登录过,不可能不对啊,难道是文件被删除或覆盖?赶紧ls .ssh瞅一眼,发现上次生成的git、git.pub文件好好的在那呢。再想想,我也没动过github上的key设置啊,在公司都是https方式push的呢。确认不是key的设置问题,在http://henzil.easymorse.com/?p=508找到了解决方案。
下面记录一下解决过程:
x*z@x*z-HP-ProBook-4446s:~/code/game_server$ git pullPermission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.x*z@x*z-HP-ProBook-4446s:~/code/game_server$ ^Cx*z@x*z-HP-ProBook-4446s:~/code/game_server$ ssh -T git@github.comPermission denied (publickey).x*z@x*z-HP-ProBook-4446s:~/code/game_server$ ls .sshls: 无法访问.ssh: 没有那个文件或目录x*z@x*z-HP-ProBook-4446s:~/code/game_server$ cd ~x*z@x*z-HP-ProBook-4446s:~$ ls .sshgit git.pub Identity Identity.pub known_hostsx*z@x*z-HP-ProBook-4446s:~$ ssh -vT git@github.comOpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug1: Connecting to github.com [192.30.252.130] port 22.debug1: Connection established.debug1: identity file /home/x*z/.ssh/id_rsa type -1debug1: identity file /home/x*z/.ssh/id_rsa-cert type -1debug1: identity file /home/x*z/.ssh/id_dsa type -1debug1: identity file /home/x*z/.ssh/id_dsa-cert type -1debug1: identity file /home/x*z/.ssh/id_ecdsa type -1debug1: identity file /home/x*z/.ssh/id_ecdsa-cert type -1debug1: identity file /home/x*z/.ssh/id_ed25519 type -1debug1: identity file /home/x*z/.ssh/id_ed25519-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2debug1: Remote protocol version 2.0, remote software version libssh-0.6.0debug1: no match: libssh-0.6.0debug1: SSH2_MSG_KEXINIT sentdebug1: SSH2_MSG_KEXINIT receiveddebug1: kex: server->client aes128-ctr hmac-sha1 nonedebug1: kex: client->server aes128-ctr hmac-sha1 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 ‘github.com‘ is known and matches the RSA host key.debug1: Found key in /home/x*z/.ssh/known_hosts:4debug1: ssh_rsa_verify: signature correctdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug1: SSH2_MSG_NEWKEYS receiveddebug1: Roaming not allowed by serverdebug1: SSH2_MSG_SERVICE_REQUEST sentdebug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug1: Authentications that can continue: publickeydebug1: Next authentication method: publickeydebug1: Trying private key: /home/x*z/.ssh/id_rsadebug1: Trying private key: /home/x*z/.ssh/id_dsadebug1: Trying private key: /home/x*z/.ssh/id_ecdsadebug1: Trying private key: /home/x*z/.ssh/id_ed25519debug1: No more authentication methods to try.Permission denied (publickey).x*z@x*z-HP-ProBook-4446s:~$ ssh-add .ssh/gitgit git.pub x*z@x*z-HP-ProBook-4446s:~$ ssh-add .ssh/gitIdentity added: .ssh/git (.ssh/git)x*z@x*z-HP-ProBook-4446s:~$ ssh-add .ssh/git.pub @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ WARNING: UNPROTECTED PRIVATE KEY FILE! @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Permissions 0644 for ‘.ssh/git.pub‘ are too open.It is required that your private key files are NOT accessible by others.This private key will be ignored.x*z@x*z-HP-ProBook-4446s:~/code/game_server$ git pullremote: Counting objects: 5, done.remote: Compressing objects: 100% (3/3), done.remote: Total 5 (delta 2), reused 5 (delta 2)Unpacking objects: 100% (5/5), done.来自 github.com:changnet/game_server d12f07e..72ef640 master -> game_server/master更新 d12f07e..72ef640Fast-forward common/CLogFile.cpp | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ common/CLogFile.h | 30 ++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 common/CLogFile.cpp create mode 100644 common/CLogFile.hx*z@x*z-HP-ProBook-4446s:~/code/game_server$
PS:ssh-add指令我也不是很熟悉,上面尝试添加public key时的警告请大家再查资料了。有时候.ssh目录下的key太多,可能会导致ssh登录不上,这时需要写ssh配置文件解决。
SSH方式登录github出现Permission denied (publickey)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。