SSH方式登录github出现Permission denied (publickey)
2014-10-24 23:50
316 查看
今天在公司上传了代码,回到家pull,结果竟然出现了“Permission denied (publickey)“这种东西。第一反应是key不对,可是上次明明用key登录过,不可能不对啊,难道是文件被删除或覆盖?赶紧ls .ssh瞅一眼,发现上次生成的git、git.pub文件好好的在那呢。再想想,我也没动过github上的key设置啊,在公司都是https方式push的呢。确认不是key的设置问题,在http://henzil.easymorse.com/?p=508找到了解决方案。
下面记录一下解决过程:
PS:ssh-add指令我也不是很熟悉,上面尝试添加public key时的警告请大家再查资料了。有时候.ssh目录下的key太多,可能会导致ssh登录不上,这时需要写ssh配置文件解决。
下面记录一下解决过程:
x*z@x*z-HP-ProBook-4446s:~/code/game_server$ git pull Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. x*z@x*z-HP-ProBook-4446s:~/code/game_server$ ^C x*z@x*z-HP-ProBook-4446s:~/code/game_server$ ssh -T git@github.com Permission denied (publickey). x*z@x*z-HP-ProBook-4446s:~/code/game_server$ ls .ssh ls: 无法访问.ssh: 没有那个文件或目录 x*z@x*z-HP-ProBook-4446s:~/code/game_server$ cd ~ x*z@x*z-HP-ProBook-4446s:~$ ls .ssh git git.pub Identity Identity.pub known_hosts x*z@x*z-HP-ProBook-4446s:~$ ssh -vT git@github.com OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /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 -1 debug1: identity file /home/x*z/.ssh/id_rsa-cert type -1 debug1: identity file /home/x*z/.ssh/id_dsa type -1 debug1: identity file /home/x*z/.ssh/id_dsa-cert type -1 debug1: identity file /home/x*z/.ssh/id_ecdsa type -1 debug1: identity file /home/x*z/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/x*z/.ssh/id_ed25519 type -1 debug1: identity file /home/x*z/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 debug1: Remote protocol version 2.0, remote software version libssh-0.6.0 debug1: no match: libssh-0.6.0 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-sha1 none debug1: kex: client->server aes128-ctr hmac-sha1 none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: RSA 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48 debug1: Host 'github.com' is known and matches the RSA host key. debug1: Found key in /home/x*z/.ssh/known_hosts:4 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/x*z/.ssh/id_rsa debug1: Trying private key: /home/x*z/.ssh/id_dsa debug1: Trying private key: /home/x*z/.ssh/id_ecdsa debug1: Trying private key: /home/x*z/.ssh/id_ed25519 debug1: No more authentication methods to try. Permission denied (publickey). x*z@x*z-HP-ProBook-4446s:~$ ssh-add .ssh/git git git.pub x*z@x*z-HP-ProBook-4446s:~$ ssh-add .ssh/git Identity 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 pull remote: 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..72ef640 Fast-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.h x*z@x*z-HP-ProBook-4446s:~/code/game_server$
PS:ssh-add指令我也不是很熟悉,上面尝试添加public key时的警告请大家再查资料了。有时候.ssh目录下的key太多,可能会导致ssh登录不上,这时需要写ssh配置文件解决。
相关文章推荐
- xshell出现unknown command "free"是因为用的是sftp,而不是 ssh方式登录
- ssh -T git@github.com出现Permission denied (publickey)
- 关于SSH登录出现Connection reset by peer 问题。
- 配置ssh用key(不用输密码)方式登录
- SSH连接GitHub出现 ssh: connect to host github.com port 22: Connection refused解决方法
- ssh 公钥认证方式登录
- ssh远程登录出现:RSA host key for *.*.*.* has changed...的解决办法
- BBS中用SSH方式登录添加附件
- 使用ssh登录远程机器出现key问题
- TeraTerm使用SSH方式登录VMware下Linux显示乱码问题
- redhat中SSH登录方式详解
- Putty登录SSH终端出现的“Access Denied”提示
- 登录ssh的时候,出现错误
- FreeBSD添加一个新用户并允许其使用ssh通过公私钥的方式登录
- 不输入密码自动通过 SSH 方式登录服务器
- SSH session key (证书认证方式SSH登录配置)
- 不输入密码自动通过SSH方式登录服务器
- Web方式登录出现如下提示The system was not able to acquire a citrix product license...的原因
- 禁止root用户直接用ssh方式登录,但可以在登录用户后切换到root用户。
- 配置Cisco路由器以SSH的方式登录