git Gitlab在克隆一个git仓库时提示输入git密码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29432899/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:52:03  来源:igfitidea点击:

Gitlab prompts for git password when cloning a git repository

gitsshgitlab

提问by mokko211

I have installed GitLab 7.9.1 using Omnibus.

我已经使用 Omnibus 安装了 GitLab 7.9.1。

Everything works. When I do a gitlab-rake gitlab:check, I get no errors.

一切正常。当我执行 gitlab-rake gitlab:check 时,我没有收到任何错误。

However, when I want to clone a repository in /var/www, the console prompts me for a git password.

但是,当我想在 /var/www 中克隆存储库时,控制台会提示我输入 git 密码。

I have added the SSH key in the Gitlab interface. However, it still asks me for a git password when I try to clone a repository.

我已经在 Gitlab 界面中添加了 SSH 密钥。但是,当我尝试克隆存储库时,它仍然要求我输入 git 密码。

What do you think?

你怎么认为?

p.s I will like to point out that I have used the Omnibus installation and not installation from source.

ps 我想指出的是,我使用的是 Omnibus 安装,而不是从源代码安装。

采纳答案by mokko211

Completely forgot to provide the solution. I actually had fixed the problem. It was a problem with the SSH keys.

完全忘了提供解决方案。我实际上已经解决了这个问题。SSH 密钥有问题。

I followed the guide on gitlabs on how to generate SSH keys. I didn't follow it properly. I missed the email address in 'ssh-keygen -t rsa -C "****@***.com"'

我按照有关如何生成 SSH 密钥的 gitlabs 指南进行操作。我没有正确地遵循它。我错过了 'ssh-keygen -t rsa -C "****@***.com"' 中的电子邮件地址

It works now.

它现在有效。

回答by jefeveizen

I hit the same issue. For me the problem was that /etc/ssh/sshd_config had an AllowGroups directive that did not include the git group created by gitlab (viewing /var/log/secure spelled it out).

我遇到了同样的问题。对我来说,问题是 /etc/ssh/sshd_config 有一个 AllowGroups 指令,该指令不包括由 gitlab 创建的 git 组(查看 /var/log/secure 将其拼写出来)。

I appended git to the set of groups listed after AllowGroups, ran sudo /sbin/service sshd restart, and then git clone git@...worked as expected. Similarly, after the fix I can run ssh [email protected]and it responds with "Welcome to GitLab..." which is an easy way to confirm the ssh keys setup is fine w/o accessing a specific repo.

我将 git 附加到 AllowGroups 之后列出的一组组, run ,sudo /sbin/service sshd restart然后git clone git@...按预期工作。同样,在修复后我可以运行ssh [email protected]它并响应“欢迎使用 GitLab...”,这是一种确认 ssh 密钥设置正常而无需访问特定存储库的简单方法。

回答by Kaustubh

Are you trying to clone with a HTTP URL? If so, git will ask for username and password. Try cloning with SSH URL; this will make git use the SSH keys that have been set up.

您是否尝试使用 HTTP URL 进行克隆?如果是这样,git 会询问用户名和密码。尝试使用 SSH URL 进行克隆;这将使 git 使用已设置的 SSH 密钥。

回答by Alexei

I have met with the same error when trying to clone using SSH on Windows:

尝试在 Windows 上使用 SSH 进行克隆时遇到了同样的错误:

Cloning into 'some_project'...
[email protected]'s password:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

克隆到“some_project”...
[email protected] 的密码:
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限并且存储库存在。

The key was accessible, but the mistake was using command prompt (cmd.exe) instead of Git Cmd (git-cmd.exe).

密钥是可访问的,但错误是使用命令提示符 (cmd.exe) 而不是 Git Cmd (git-cmd.exe)。

回答by adamsmith

Possible causes:

可能的原因:

  1. you haven't added your local ssh pubkey (~/.ssh/id_rsa.pub) to your Gitlab account.
  2. or your ssh pubkey files has disallowed file mode (e.g.: readable by others). In this case just chmod 400 ~/.ssh/id_rsa*
  1. 您尚未将本地 ssh 公钥 (~/.ssh/id_rsa.pub) 添加到您的 Gitlab 帐户。
  2. 或者您的 ssh 公钥文件不允许文件模式(例如:其他人可读)。在这种情况下只是chmod 400 ~/.ssh/id_rsa*