今天在公司上传了代码,回到家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 1286 Necklace of Beads (polya(旋转+翻转)+模板)

      Description Beads of red, blue or green colors are connected together into a circular necklace of ...

  2. Wikioi 1080一维树状数组

    半个月时间最终把那些杂七杂八的学完了,尽管学完也,也仅仅是有了个模板,自己手敲还是不太行.所以如今開始要疯狂刷题了! ! .!!! 这题裸的树状数组.曾经写那道<敌兵布阵>的时候写过,所以 ...

  3. JMeter简单的性能测试实例

    JMeter基础之——一个简单的性能测试 我们了解了jmeter的一此主要元件,那么这些元件如何使用到性能测试中呢.这一节创建一个简单的测试计划来使用这些元件.该计划对应的测试需求. 1)测试目标网站 ...

  4. [RxJS] Sharing Streams with Share

    A stream will run with each new subscription added to it. This lesson shows the benefits of using sh ...

  5. 为iPhone 6设计自适应布局

    Apple从iOS 6加入了Auto Layout后开始就比较委婉的开始鼓励.建议开发者使用自适应布局,但是到目前为止,我感觉大多数开发者一直在回避这个问题,不管是不是由于历史原因造成的,至少他们在心 ...

  6. Verilog 读写文件

    Verilog 读写文件 在数字设计验证中,有时我们需要大量的数据,这时可以通过文件输入,有时我们需要保存数据,可以通过写文件保存. 读写文件testbench module file_rw_tb() ...

  7. MySql查看表信息

    SELECT TABLE_NAME, TABLE_COMMENT -- 指定信息列 FROM `information_schema`.`tables` A WHERE A.`TABLE_SCHEMA ...

  8. hdu4006 优先队列

    A - 签到 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65768KB     64bit I ...

  9. C++中string类的基本用法

    #include <iostream> #include <set> using namespace std; int main() { string line; getlin ...

  10. Python 学习日记(第三周)

    知识回顾 在上一周的学习里,我学习了一些学习Python的基础知识下面先简短的回顾一些: 1Python的版本和和安装 Python的版本主要有2.x和3.x两个版本这两个版本在语法等方面有一定的区别 ...