XPermission denied (publickey),v如何才能解决?

连接github时,公钥出现问题。执行 ssh -vT git@github.com后出现如下显示:
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to http://github.com [204.232.175.90] port 22.
debug1: Connection established.
debug1: identity file /home/chengsh/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/chengsh/.ssh/id_rsa-cert type -1
debug1: identity file /home/chengsh/.ssh/id_dsa type -1
debug1: identity file /home/chengsh/.ssh/id_dsa-cert type -1
debug1: identity file /home/chengsh/.ssh/id_ecdsa type -1
debug1: identity file /home/chengsh/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-6+squeeze1+github12
debug1: match: OpenSSH_5.5p1 Debian-6+squeeze1+github12 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_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/chengsh/.ssh/known_hosts:1
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: Offering RSA public key: /home/chengsh/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
Agent admitted failure to sign using the key.
debug1: Trying private key: /home/chengsh/.ssh/id_dsa
debug1: Trying private key: /home/chengsh/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey).

  1. 首先确认下你的Linux/Mac/Wins当前用户对于 git 工程所在的本地文件夹,
    是否具有777权限,没有的话,先设置一下.因为即使你把 root 用户的 ssh 加到 GitHub 后, 操作系统的子账户并不能具有
    ssh
    的权限.如果具有777权限,可以进行下面的检查:下面的方案前提是你对文件夹有777权限.电脑只有一个git环境如果你的电脑只有一个git环境,那么极大多数情况是由于
    GitHub 账号没有设置 ssh 公钥信息所致。 前往 GitHub 网站的"account
    settings"依次点击"Setting -> SSH Keys"->"New SSH
    key"Title处填写“id_rsa.pub”或其他任意信息。 key处原样拷贝下面命令的打印 ~/.ssh/id_rsa.pub
    文件的内容:cat ~/.ssh/id_rsa.pub如没有则按下述方法生成: ssh-keygen -t
    rsa输入文件名的地方输入可以输入自定义文件名,默认是id_rsa,然后一路回车…
    注意如果自定义文件名的话,需要加一个config文件,下文有介绍。最后,输入ssh -T
    git@github.com如果没有报错,再尝试输出就应该有了cat ~/.ssh/id_rsa.pub如果报错了,或者说设置了
    sshkey 还是 permission denied 怎么回事?回到如下命令,检查当前配置的SSH对应的git账号;ssh -T
    git@github.com然后用如下命令(id_rsa对应目标账户的私钥)命令,制定目标Git账号ssh-add -K
    ~/.ssh/id_rsa电脑有多个git环境如果尝试了上面的方法还是不行,那么可能你用了多个密钥,你在新建秘钥的时候使用了自定义的名称,比如
    github_rsa,你需要再配置一个 config 文件cd ~/.ssh/

vi config输入以下内容:Host github
User git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_rsa
ServerAliveInterval 300
ServerAliveCountMax 10ESC+:wq保存退出重新尝试以下命令即可搞定:ssh -T git@github.comssh-add -K ~/.ssh/github_rsa

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值