git Git和ssh授权
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2546005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git and ssh authorizating
提问by Max Frai
I can't login to github with generated ssh-keys. I've followed this manual: http://help.github.com/linux-key-setupbut at step:
我无法使用生成的 ssh 密钥登录到 github。我已经按照本手册:http: //help.github.com/linux-key-setup但在步骤:
I get:
我得到:
Agent admitted failure to sign using the key. Permission denied (publickey).
代理承认未能使用密钥签名。权限被拒绝(公钥)。
What's wroing? And, of course, I'm adding my own user email.
怎么了?而且,当然,我正在添加我自己的用户电子邮件。
Tried dsa-key, the same thing.
试过 dsa-key,同样的事情。
采纳答案by prasadvk
From the troubleshooting guide:
从故障排除指南:
Permission denied (publickey)
This is usually caused when ssh cannot find your keys. Make sure your key is in the default location, ~/.ssh. If you run ssh-keygen again and just press enter at all 3 prompts it will be placed here automatically. Then you can add the contents of id_rsa.pub to my github keys. If id_rsa.pub doesn't work try id_dsa.pub. You might need to generate a new dsa key with ssh-keygen -t dsa if you just have an rsa key.
If you are still having problems and none of the above worked, you may have a blacklisted key from a debian open-ssh bug. you should update open-ssh and re-generate your keys.
权限被拒绝(公钥)
这通常是在 ssh 找不到您的密钥时引起的。确保您的密钥位于默认位置 ~/.ssh。如果您再次运行 ssh-keygen 并在所有 3 个提示处按回车键,它将自动放置在这里。然后你可以将 id_rsa.pub 的内容添加到我的 github 密钥中。如果 id_rsa.pub 不起作用,请尝试 id_dsa.pub。如果您只有 rsa 密钥,则可能需要使用 ssh-keygen -t dsa 生成新的 dsa 密钥。
如果您仍然遇到问题并且上述方法均无效,则您可能有一个来自 debian open-ssh 错误的列入黑名单的密钥。您应该更新 open-ssh 并重新生成您的密钥。
So, just to check - are your keys available under ~/.ssh/ as id_rsa and id_rsa.pub or otherwise, are you specifying their use?
所以,只是为了检查 - 您的密钥在 ~/.ssh/ 下是否可用作为 id_rsa 和 id_rsa.pub 或其他方式,您是否指定了它们的用途?
回答by jamesc
I found this which helped me greatly http://playwithrubyandrails.blogspot.com/2011/04/process-for-deploying-app-on-heroku.html
我发现这对我有很大帮助http://playwithrubyandrails.blogspot.com/2011/04/process-for-deploying-app-on-heroku.html
ssh-add ~/.ssh/id_rsa
solved my problem after generating the relevant keys
ssh-add ~/.ssh/id_rsa
生成相关密钥后解决了我的问题
回答by Samundra
After generating the ssh keys I executed the command listed below as suggested by jamesw.
生成 ssh 密钥后,我按照 jamesw 的建议执行了下面列出的命令。
$ ssh-add ~/.ssh/id_rsa
I entered my password. Then retried to clone the heroku repository. This time it worked fine.
我输入了我的密码。然后重试克隆heroku存储库。这次效果很好。
回答by prasadvk
This is a ubuntu problem. Exporting "SSH_AUTH_SOCK=0" solved the problem for me. More details can be found at - https://bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/201786.
这是一个 ubuntu 问题。导出“SSH_AUTH_SOCK=0”为我解决了这个问题。更多细节可以在 - https://bugs.launchpad.net/ubuntu/+source/gnome-keyring/+bug/201786找到。
回答by clayzermk1
I was able to get gitlab working thanks to this thread (I know that's not github).
由于这个线程(我知道那不是 github),我能够让 gitlab 工作。
I too found the answer by @jamesw to be correct.
我也发现@jamesw 的答案是正确的。
I ended up having to delete my known_hosts
file and recreate my ssh key with the same password as my gitlab account.
我最终不得不删除我的known_hosts
文件并使用与我的 gitlab 帐户相同的密码重新创建我的 ssh 密钥。
Then I did the ssh-add
and did a git push -u origin master
. Success!
然后我做了ssh-add
和做了一个git push -u origin master
。成功!
Thanks for the help everyone.
谢谢大家的帮助。
UPDATE:
I decided to remake my ssh key without a password and ran into this error again.
更新:
我决定在没有密码的情况下重新制作我的 ssh 密钥并再次遇到此错误。
This time, I was able to copy my old known_hosts
to the new .ssh/
and simply run the ssh-add
.
这一次,我能够将旧的复制known_hosts
到新的.ssh/
并简单地运行ssh-add
.
回答by kirancodify
This issue occurs mainly due to the following reasons :
出现此问题主要是由于以下原因:
- The public and private key pair is wrong. You have to verify the key public key on the server/ your git account where you have placed the public key. Even a small space or tab will result in the error.
If you are sure your public key is correct, then check the format of public key in your ~/.ssh folder in your machine. For openssh you cannot use a public key in puttygen format and visa-versa. To change the format you can use the following command using your private key
$ ssh-keygen -e -f ~/.ssh/id_rsa > ~/.ssh/id_rsa_com.pub
$ ssh-keygen -i -f ~/.ssh/id_rsa_com.pub > ~/.ssh/id_rsa.pubFinally check if you have added your keys to the ssh client in your system. You can do so by using the following commands
$ eval "$(ssh-agent -s)"
$ ssh-add
- 公私钥对不对。您必须在您放置公钥的服务器/您的 git 帐户上验证密钥公钥。即使是很小的空格或制表符也会导致错误。
如果您确定您的公钥是正确的,请检查您机器中 ~/.ssh 文件夹中的公钥格式。对于 openssh,您不能使用 puttygen 格式的公钥,反之亦然。要更改格式,您可以使用您的私钥使用以下命令
$ ssh-keygen -e -f ~/.ssh/id_rsa > ~/.ssh/id_rsa_com.pub
$ ssh-keygen -i -f ~/.ssh/id_rsa_com.pub > ~/.ssh/id_rsa.pub最后检查您是否已将密钥添加到系统中的 ssh 客户端。您可以使用以下命令执行此操作
$ eval "$(ssh-agent -s)"
$ SSH 添加
回答by ankitk
Above Accepted solution did not work for me, but this worked http://ripan27.wordpress.com/2010/04/01/ssh-gitgithub-com-agent-admitted-failure-to-sign-using-the-key-permission-denied-publickey/
以上接受的解决方案对我不起作用,但这有效 http://ripan27.wordpress.com/2010/04/01/ssh-gitgithub-com-agent-admitted-failure-to-sign-using-the-key-权限被拒绝的公钥/
回答by Jakub Nar?bski
回答by Jakub Nar?bski
I encounterded same error when I copied id_rsa and idrsa.pub from another os. These files were 644 permission. So I changed it to 600. the error was fixed.
当我从另一个操作系统复制 id_rsa 和 idrsa.pub 时遇到了同样的错误。这些文件有 644 权限。所以我把它改成了600。错误被修复了。