如何在 gitlab 中将现有的 ssh 密钥添加到项目的部署密钥

How to add existing ssh key to project's deploy key in gitlab

我正在使用 gitlab.com,但我不太习惯使用 SSH 密钥。顺便说一句,我已经使用 cmd 和 Git bash 在我的 Windows 8 PC 中成功创建了一个 SSH 密钥。我已经设法将其添加到我的 gitlab 用户帐户中。

现在在我的项目中 "Deploy Keys" 我看到:

如果我也尝试在此处粘贴相同的密钥,则不会添加,因为它已被占用。

问题可以用以下两个之一来回答:

您不能同时拥有一把标准钥匙和 "read-only"。没有任何意义。

如果你想"push into private repo of gitlab without username and password prompt"。只需将密钥添加为普通的 SSH 密钥即可:

Profile Settings -> SSH keys

是您应该为 read/write 访问添加密钥的正确位置。

部署密钥用于只读访问!


根据评论编辑: 如果您仍然使用 https,您还需要更改协议。选项 url 中的 .git/confighttps://gitlab.com/ 开始更改为 git@gitlab.com: