简体   繁体   English

错误:权限被拒绝(公钥)

[英]Error: Permission denied (publickey)

Following this post to fix the following error: 按照这篇文章来修复以下错误:

>> ssh -vT git@github.com
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/user/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug1: Connecting to github.com [207.97.227.239] port 22.
debug1: Connection established.
debug1: identity file /Users/user/.ssh/id_rsa type 1
debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
debug1: identity file /Users/user/.ssh/id_dsa type -1
debug1: identity file /Users/user/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5github2
debug1: match: OpenSSH_5.1p1 Debian-5github2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
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: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/user/.ssh/known_hosts:10
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: /Users/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/user/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

Through the post made sure that I have a key and SSH is using it. 通过帖子确保我有一个密钥,并且SSH正在使用它。 I have even verified that the public key is attached to my github account. 我什至已验证公钥已附加到我的github帐户。 Not sure of the -1 in the last 3 lines? 不确定最后3行中的-1吗? Saw all the related posts but no help. 看到所有相关帖子,但没有帮助。

 debug1: identity file /Users/user/.ssh/id_rsa type 1
    debug1: identity file /Users/user/.ssh/id_rsa-cert type -1
    debug1: identity file /Users/user/.ssh/id_dsa type -1
    debug1: identity file /Users/user/.ssh/id_dsa-cert type -1

I was doing ssh -T git@github.com . 我正在做ssh -T git@github.com I had to do ssh -T git@github.company's-github-account-name.com . 我不得不做ssh -T git@github.company's-github-account-name.com All set now. 全部设置好了。

The most likely problem, it seems, is that the public key isn't actually correctly attached to your github account. 看来,最可能的问题是公钥实际上没有正确地附加到您的github帐户。 Can you confirm that the output of 您可以确认输出

ssh-keygen -y -f /Users/user/.ssh/id_rsa

is exactly the same as what you put in Github, and that if you do 与您在Github中放置的内容完全相同,如果您这样做

ssh-keygen -y -f /Users/user/.ssh/id_rsa > tmp
ssh-keygen -l -f tmp

..that the fingerprint shown matches exactly one of the fingerprints shown at https://github.com/settings/ssh ? ..显示的指纹与https://github.com/settings/ssh所示的指纹之一完全匹配吗?


Edit : you confirmed. 编辑 :您确认。 It looks like you've done everything right, then. 看来您已正确完成所有操作。 I can't think of much more that could be going wrong. 我想不出更多可能出错的地方。 I suppose you might be getting the wrong remote host (the IP is right, but a malicious person or a misbehaving corporate firewall could still be sending the packets to the wrong place). 我想您可能得到了错误的远程主机(IP是正确的,但是恶意人员或行为不当的公司防火墙仍可能会将数据包发送到错误的位置)。 You can check this by seeing what fingerprint you've stored in your known_hosts file: 您可以通过查看在known_hosts文件中存储的指纹来检查此情况:

ssh-keygen -F github.com > tmp
ssh-keygen -l -f tmp

The output should start with: 输出应以以下内容开头:

2048 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48

If it does, then I suppose it might be a problem on the github side after all. 如果确实如此,那么我想毕竟这可能是github方面的问题。 Maybe they have some sort of delay in between receiving your public key and propagating it to the main ssh server. 在接收您的公钥并将其传播到主ssh服务器之间,它们之间可能会有某种延迟。 You probably ought to try the "contact a human" link at the bottom of the page you cited. 您可能应该尝试在引用页面底部的“联系人类”链接。

Extensive troubleshooting of this GIT issue “Git – Permission denied (publickey)” can be done with the below command: 可以使用以下命令对GIT问题“ Git –权限被拒绝(公钥)”进行广泛的故障排除:

ssh -vT git@github.com
  1. Navigate to .ssh directory inside your home directory 导航到主目录中的.ssh目录

     cd ~/.ssh 
  2. Generate the public/private rsa key pair 生成公共/私有rsa密钥对

     ssh-keygen 
  3. Copy the SSH key to the clipboard using the below command 使用以下命令将SSH密钥复制到剪贴板

     cat id_rsa.pub | clip 
  4. Navigate to your GIT repository in https://github.com/ https://github.com/导航到您的GIT存储库

  5. Go to Account Settings –> SSH Keys 转到帐户设置–> SSH密钥

  6. Click on Add SSH key and store the key 单击添加SSH密钥并存储密钥

I agree with the answer posted by @Ava. 我同意@Ava发布的答案。 Using ssh -T git@github."company's_github_account".com It worked for me. 使用ssh -T git@github."company's_github_account".com它对我ssh -T git@github."company's_github_account".com Many times, we do not realize that a simple fix exists for seemingly complex problems. 很多时候,我们没有意识到针对看似复杂的问题存在一个简单的解决方案。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SSH错误:权限被拒绝(publickey,gssapi-with-mic) - SSH Error: Permission denied (publickey,gssapi-with-mic) SourceTree 总是权限被拒绝(公钥) - SourceTree always Permission denied (publickey) GitLab SSH 权限被拒绝(公钥) - GitLab SSH Permission denied (publickey) OpenShift中的权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic) - Permission denied (publickey,gssapi-keyex,gssapi-with-mic) in OpenShift Permission denied (publickey)(我可以登录Tiger但不能上传文件) - Permission denied (publickey)(I can log in Tiger but can not upload the file) 自从升级到macOS 10.12(Sierra)以来,在使用Capistrano部署代码时遇到了问题,“Permission denied(publickey)”。 - Problems deploying code with Capistrano since upgrading to macOS 10.12 (Sierra), “Permission denied (publickey).” git@github.com:执行 brew cask 安装“程序”时权限被拒绝(公钥) - git@github.com: Permission denied (publickey) when doing a brew cask install “program” moffodb在mac权限被拒绝时出错 - Error with mongodb on mac permission denied 无法通过ubuntu中的配置文件将ssh连接到ec2。 权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic) - Unable to connect ssh to ec2 through config file in ubuntu. Permission denied (publickey,gssapi-keyex,gssapi-with-mic) 代码签名框架失败并显示“权限被拒绝”错误 - Code signing a framework fails with “Permission denied” error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM