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*[email protected]*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*[email protected]*z-HP-ProBook-4446s:~/code/game_server$ ^C
x*[email protected]*z-HP-ProBook-4446s:~/code/game_server$ ssh -T [email protected]
Permission denied (publickey).
x*[email protected]*z-HP-ProBook-4446s:~/code/game_server$ ls .ssh
ls: 无法访问.ssh: 没有那个文件或目录
x*[email protected]*z-HP-ProBook-4446s:~/code/game_server$ cd ~
x*[email protected]*z-HP-ProBook-4446s:~$ ls .ssh
git  git.pub  Identity  Identity.pub  known_hosts
x*[email protected]*z-HP-ProBook-4446s:~$ ssh -vT [email protected]
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*[email protected]*z-HP-ProBook-4446s:~$ ssh-add .ssh/git
git      git.pub
x*[email protected]*z-HP-ProBook-4446s:~$ ssh-add .ssh/git
Identity added: .ssh/git (.ssh/git)
x*[email protected]*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*[email protected]*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*[email protected]*z-HP-ProBook-4446s:~/code/game_server$ 

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

时间: 2024-08-25 07:14:11

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

github出现Permission denied (publickey) 的解决方法

今天git上传的时候出现了如下错误: Permission denied (publickey).fatal: The remote end hung up unexpectedly 原因分析: ssh key 过期,重新创建即可. 步骤如下: 1.ssh-keygen (注意短横线前后都没有空格) 2.Enter, Enter, Enter... 3.~/.ssh 4.vim id_rsa.pub 5.github页面中,setting->SSH Keys->Add SSH Key 6.ti

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 (publickey). fatal: Could not read from remote repository." LZ用git不久,第一次从github clone项目遇见一下问题 $ git clone [email protected]:xiaolongzuo/niubi-job.gitCl

ssh登录服务器出现Permission denied (publickey,gssapi-keyex,gssapi-with-mic)警告

在一次上传网站到服务器的过程中出现了Permission denied (publickey,gssapi-keyex,gssapi-with-mic)警告,网上有很多解决的办法,比如https://www.cnblogs.com/xubing-613/p/6844564.html的方法就不错.我是在mac环境下上传的项目,这里我使用的ssh工具是国产的finalshell.所以我简单记录下我使用命令行修改的过程. 我是使用的秘钥对进行ssh登录的,但是在通过finalshell登录时老是说我的

ubuntu 下使用git/github [Error: Permission denied (publickey) ]

1.背景 之前因为误删了文件,导致程序和软件都被删除,损失是心疼的,里面有这好几个月的练习代码,一步一步走来的,就这样没了. 为了避免重蹈覆辙,于是准备使用git版本控制.在此记录一下,在配置git时候遇到的一些小问题. 2.准备工作 本机系统:ubuntu 14.04 整个配置过程是在廖雪峰的官方网站的指导下进行,因为其讲解较为详细,语言通俗易通, 按照流程配置基本没有问题.但因为环境和操作的不同,会出现问题也是在所难免的. 3.遇到的问题 在git创建仓库–>初始化–>add添加到暂存区–

windows下github 出现Permission denied (publickey).解决方法

今天在学习github的时候遇到了一些问题,然后爬了一会,找到了解决方法记录下来,以防忘记,当然能帮助别人最好啦! github教科书传送门:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000 再学习到"添加远程仓库"的时候遇到了 Permission denied (publickey) 这个问题, 总结来说以前的步骤如下所示: 1.git config --global

ssh -T [email protected]出现Permission denied (publickey)

参考自:http://blog.csdn.net/sunnypotter/article/details/18948053 参考自:http://stackoverflow.com/questions/18293405/ssh-t-gitgithub-com-permission-denied-publickey 升级win10后,重新安装git,在配置ssh到github的时候出现了该问题,google之,整理出解决方案如下 在生成ssh后在你的git工作根路径下问出现两个文件(“yourna

github windows配置以及ssh生成 Permission denied (publickey)

1:进入cmd命令下,或者可以使用GIt工具   (如果出现了 Permission denied 或者配置多个SSH Key跳第6步) git工具  下载地址:https://git-scm.com/downloads 安装 2:进入到 用户/.ssh目录下  cd Users\****\.ssh 如果没有这个目录(.ssh)自行创建 (***表示你的家目录) 3:生成KEY ssh-keygen -t rsa -C "*****" -t   生成dsa私钥和dsa公钥:默认使用ds

$ ssh -T -v [email protected]_在本地用ssh连接github出错[email protected]: Permission denied (publickey).

$ ssh -T -v [email protected]报错: debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /Users/eveline/.ssh/id_rsa debug1: Trying private key: /Users/eveline/.ssh/id_dsa debug1:

ssh免密码登录Permission denied (publickey,gssapi-keyex,gssapi-with-mic) 的解决方案!

当出现Permission denied (publickey,gssapi-keyex,gssapi-with-mic) 警告的时候,恭喜你,你已经离成功很近了. 远程主机这里设为slave2,用户为Hadoop. 本地主机设为slave1 以下都是在远程主机slave2上的配置,使得slave1可以免密码连接到slave2上.如果想免密码互联,原理一样的,在slave1上也这么配置即可! (1)首先:配置ssh服务器配置文件. 在root 用户下才能配置. vi /etc/ssh/sshd_