今天在公司上传了代码,回到家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 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 Jan
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line : Applying options for *
debug1: Connecting to github.com [192.30.252.130] port .
debug1: Connection established.
debug1: identity file /home/x*z/.ssh/id_rsa type -
debug1: identity file /home/x*z/.ssh/id_rsa-cert type -
debug1: identity file /home/x*z/.ssh/id_dsa type -
debug1: identity file /home/x*z/.ssh/id_dsa-cert type -
debug1: identity file /home/x*z/.ssh/id_ecdsa type -
debug1: identity file /home/x*z/.ssh/id_ecdsa-cert type -
debug1: identity file /home/x*z/.ssh/id_ed25519 type -
debug1: identity file /home/x*z/.ssh/id_ed25519-cert type -
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6..1p1 Ubuntu-2ubuntu2
debug1: Remote protocol version 2.0, remote software version libssh-0.6.
debug1: no match: libssh-0.6.
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 ::ac:a5:::2d:::1b::4d:eb:df:a6:
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/x*z/.ssh/known_hosts:
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 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: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta )
Unpacking objects: % (/), done.
来自 github.com:changnet/game_server
d12f07e..72ef640 master -> game_server/master
更新 d12f07e..72ef640
Fast-forward
common/CLogFile.cpp | +++++++++++++++++++++++++++++++++++++++++++++++++++++
common/CLogFile.h | ++++++++++++++++++++++++++
files changed, insertions(+)
create mode common/CLogFile.cpp
create mode common/CLogFile.h
x*z@x*z-HP-ProBook-4446s:~/code/game_server$

  PS:ssh-add指令我也不是很熟悉,上面尝试添加public key时的警告请大家再查资料了。有时候.ssh目录下的key太多,可能会导致ssh登录不上,这时需要写ssh配置文件解决。

SSH方式登录github出现Permission denied (publickey)的更多相关文章

  1. SSH Key连接github提示Permission denied (publickey).错误

    root@debian64:/home/xiaoliuzi/.ssh/key_backup# ssh -T git@github.com The authenticity of host 'githu ...

  2. $ ssh -T -v git@github.com_在本地用ssh连接github出错_git@github.com: Permission denied (publickey).

    $ ssh -T -v git@github.com报错: debug1: Authentications that can continue: publickey debug1: Next auth ...

  3. github:当你想要使用VSCODE开心提交代码时,出现Git:git@github.com:Permission denied(publickey)解决方案

    当你想要使用VSCODE开心提交代码时,出现Git:git@github.com:Permission denied(publickey)弹框 图片: 原因:电脑公钥(publickey)未添加至gi ...

  4. git克隆出错 github clone Permission denied (publickey) fatal Could not read from remote repo

    原文网址:http://blog.csdn.net/feeling450/article/details/53067563 github clone "Permission denied ( ...

  5. 使用Git出现以下错误"Git@github.com: Permission denied (publickey). Could not read from remote repository."解决方案

    转载于:https://blog.csdn.net/dotphoenix/article/details/100130424 git@github.com: Permission denied (pu ...

  6. git实战中遇到git@github.com: Permission denied (publickey).的问题

    一.问题我们在使用git的时候会建立一个私钥和一个公钥来完成彼此的通讯,因此如何使用给一个指令建立一个秘钥至关重要.但是我在实践的过程中出现了git@github.com: Permission de ...

  7. git@github.com: Permission denied (publickey).////remote: Permission to xxx/test.git denied to xxx.等权限问题

    Error msg git@github.com: Permission denied (publickey) 或者: remote: Permission to xxx/test.git denie ...

  8. [置顶] github 出现 Permission denied (publickey)的解决

    今天写了一篇博客,想push到github上的时候出现了以下错误 Permission denied (publickey). fatal: The remote end hung up unexpe ...

  9. clone github报Permission denied (publickey) 解决方案

    问题描述 问题产生的原因,不是很清楚,就不管了.在执行git clone git@github.com:****.git 的时候报了Permission denied (publickey). War ...

随机推荐

  1. poj 2010 Moo University - Financial Aid(优先队列(最小堆)+ 贪心 + 枚举)

    Description Bessie noted that although humans have many universities they can attend, cows have none ...

  2. html5 app图片预加载

    function Laimgload(){} //图片预加载JS Laimgload.prototype.winHeight = function(){ //计算页面高度 var winHeight ...

  3. WebService- 使用 CXF 开发 SOAP 服务

    选框架犹如选媳妇,选来选去,最后我还是选了“丑媳妇(CXF)”,为什么是它?因为 CXF 是 Apache 旗下的一款非常优秀的 WS 开源框架,具备轻量级的特性,而且能无缝整合到 Spring 中. ...

  4. rac_进行grid自检时提示运行runfixup.sh脚本一例

    原创作品,出自 "深蓝的blog" 博客,欢迎转载,转载时请务必注明下面出处,否则追究版权法律责任. 深蓝的blog:http://blog.csdn.net/huangyanlo ...

  5. oracle插入特殊字符'&'问题

    oracle转义字符开关:set define off   /   show define

  6. JMeter Building a Database Test Plan

    Building a Database Test Plan In this section, you will learn how to create a basic Test Planto test ...

  7. Merge Sorted Array 合并数组并排序

    Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note:Yo ...

  8. "客户端无法连接到远程计算机"错误的解决方法

    问题: 客户端无法连接到远程计算机. 可能没有启用远程连接或者计算机太忙不能接受新的连接. 也可能是网络问题阻止连接.请稍后重新尝试连接. 如果问题仍然存在 请与管理员联系. 解决方法: 1.首先确认 ...

  9. hdu 1263 水果

    Problem Description 夏天来了~~好开心啊,呵呵,好多好多水果~~ Joe经营着一个不大的水果店.他认为生存之道就是经营最受顾客欢迎的水果.现在他想要一份水果销售情况的明细表,这样J ...

  10. 使用python发邮件

    使用python发邮件 网上有很多发邮件的例子,本人在网上找了一份,稍加修改后使用 上源码 # encoding=utf-8 from email.mime.image import MIMEImag ...