Git 要求输入 git@git.repo.local 密码

Git asking for git@git.repo.local password

我正在尝试使用 SSH 身份验证克隆或推送到我们 Git 实验室服务器上的一个空存储库,但每当我尝试时,我都会被要求输入 git 密码(使用 Git Bash):

myname@PC0016 MINGW64 /c/users/myname/dev
$ git clone git@git.repo.local:android/myApp.git
Cloning into 'myApp'...
git@git.repo.local's password:

我已经尝试了我的密码和管理员给我的 Git 密码,但我得到:

Please make sure you have the correct access rights
and the repository exists.

为什么我在 Gitlab 中将 SSH 密钥添加到项目文件后需要提供此密码?我错过了什么?谢谢!

您需要 ssh 密钥才能跳过身份验证阶段。 通常我执行的操作是:

  1. 如果您还没有 ssh 密钥,请生成一个:instructions
  2. 将密钥添加到gitlab:page,
  3. 通过 ssh 克隆存储库:项目主页中的克隆或下载按钮,
  4. 设置提交消息的用户名或电子邮件地址:instructions,
  5. 玩得开心!!!

如果您正确设置密钥,一切都会好起来的。

创建一个 ssh_config`,您可以在其中将您的客户端指向您的身份文件:

Host git.repo.local
  IdentityFile C:\Users\myname\.ssh\id_rsa

同时将此文件存储在 /z/.ssh/config 中以供您的客户阅读。