git Gitlab 密钥格式问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33302130/
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
Gitlab key format issue
提问by jqheart
I am facing a strange situation where I am using gitlab account to handle my code. I am using ssh protocol to access the repo. I am able to pull the code but I am receiving the following error while I try to push the code. This could be something silly on my side. But I have the keys stored in my gitlab profileand able touse it to pull the code.
我正面临一个奇怪的情况,我使用 gitlab 帐户来处理我的代码。我正在使用 ssh 协议访问 repo。我能够拉取代码,但在尝试推送代码时收到以下错误。这对我来说可能是愚蠢的。但是我将密钥存储在我的 gitlab 配置文件中,并且能够使用它来提取代码。
Error :
错误 :
$ git push origin master
key_load_public: invalid format
Enter passphrase for key '/c/Users/username/.ssh/id_rsa':
Access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
回答by jqheart
Finally I have been able to resolve this issue and I am posting it for other users. If the keys generated by puttyis not helping you to access the gitlab repo, try generating the keys from gitbashterminal using the command ssh-keygen
and save the files in .ssh
folder of your user account.
最后我已经能够解决这个问题,我把它发布给其他用户。如果putty生成的密钥不能帮助您访问 gitlab 存储库,请尝试使用命令从gitbash终端生成密钥ssh-keygen
并将文件保存在.ssh
您的用户帐户的文件夹中。
The linux style key generation made my life easy as I was trying to generate key in windows environment with putty keygen.
linux 风格的密钥生成让我的生活变得轻松,因为我试图在 Windows 环境中使用 putty keygen 生成密钥。
Hope this helps somebody.
希望这可以帮助某人。
回答by Glen Blanchard
PuTTYGen can generate the correct OpenSSH keys.
PuTTYGen 可以生成正确的 OpenSSH 密钥。
- Generate your key file, save the private key (with or without a passphrase)
- Add your username/email address as the comment
- Copy the contents of the generated key and paste it into your id_rsa.pub
- Export the OpenSSH private key using the menu and save it as id_rsa
- 生成您的密钥文件,保存私钥(带或不带密码)
- 添加您的用户名/电子邮件地址作为评论
- 复制生成的密钥的内容并将其粘贴到您的 id_rsa.pub
- 使用菜单导出 OpenSSH 私钥并将其保存为 id_rsa
回答by ErichBSchulz
I fixed my error by regenerating my public key (id_es.pub
) from my private key (id_es
) :
我通过id_es.pub
从我的私钥 ( id_es
)重新生成我的公钥 ( ) 来修复我的错误:
ssh-keygen -f ~/.ssh/id_es -y > ~/.ssh/id_es.pub
回答by jaroslawj
If you upload 'vanilla' putty key, solution is probably described here: https://gitlab.com/gitlab-org/gitlab-ce/issues/786
如果您上传“vanilla”腻子密钥,则可能在此处描述了解决方案:https: //gitlab.com/gitlab-org/gitlab-ce/issues/786