bash 如何将现有的 ssh 密钥添加到 gitlab 中项目的部署密钥
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36777251/
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
How to add existing ssh key to project's deploy key in gitlab
提问by Mayeenul Islam
I'm using gitlab.com, and I'm not that used to with SSH Keys. BTW I've managed to create a SSH Key in my Windows 8 PC using cmd and Git bash. And I've managed to add that to my gitlab user account.
我正在使用 gitlab.com,但我不习惯使用 SSH 密钥。顺便说一句,我已经设法使用 cmd 和 Git bash 在我的 Windows 8 PC 中创建了一个 SSH 密钥。我已经设法将它添加到我的 gitlab 用户帐户中。
Now in my project "Deploy Keys" I'm seeing:
If I try to paste the same key here too, it's not adding because it's already taken.
如果我也尝试在此处粘贴相同的密钥,则不会添加,因为它已被占用。
The question can be answered by either of the following two:
该问题可以通过以下两种方式中的任何一种来回答:
- How can I add the existing one then? or,
- How can I make my SSH key active for my project, so that I can push into private repo of gitlab without username and password prompt?
- 那么如何添加现有的呢?或者,
- 如何让我的 SSH 密钥为我的项目激活,以便我可以在没有用户名和密码提示的情况下推送到 gitlab 的私有仓库?
回答by Jakuje
You can't have one key both standard and "read-only". It does not make any sense.
您不能同时拥有标准和“只读”密钥。这没有任何意义。
If you want to "push into private repo of gitlab without username and password prompt". Just add the key as normal SSH-Key and you are good:
如果您想“在没有用户名和密码提示的情况下推送到 gitlab 的私有仓库”。只需将密钥添加为普通的 SSH-Key 即可:
Profile Settings -> SSH keys
is the correct place where you should add your keys for read/write access.
是您应该添加密钥以进行读/写访问的正确位置。
Deploy keys are for read-only access!
部署密钥用于只读访问!
Edit from comments:Also you need to change protocol, if you still use https
. Change in .git/config
in option url
beginning from https://gitlab.com/
to [email protected]:
从评论中编辑:如果您仍然使用https
. .git/config
选项中的更改url
从https://gitlab.com/
到[email protected]: