GitLab git 用户密码

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

GitLab git user password

gitgitlab

提问by Alvin

I have just installed GitLab.

我刚刚安装了 GitLab。

I created a project called project-x.

我创建了一个名为 project-x 的项目。

I have created few users and assigned it to the project.

我创建了几个用户并将其分配给项目。

Now I tried to clone:

现在我尝试克隆:

 git clone [email protected]:project-x.git

It prompted me for a password.

它提示我输入密码。

What password should I use?

我应该使用什么密码?

采纳答案by VonC

It prompted me for password.

它提示我输入密码。

It shouldn't.
If you have the right public/private key representing a user authorized to access project-x, then gitlab won't ask you for anything.

它不应该。
如果您拥有代表有权访问的用户的正确公钥/私钥project-x,则 gitlab 不会要求您提供任何内容。

But that supposes that ssh -vT [email protected]is working first.

但这假设ssh -vT [email protected]首先起作用。

回答by d.raev

Not strictly related to the current scenario. Sometimes when you are prompted for password, it is because you added the wrong* origin format (HTTPS instead of SSH)

与当前场景没有严格关系。有时提示您输入密码,是因为您添加了错误的*来源格式(HTTPS 而不是 SSH)

HTTP(S)protocol is commonly used for public repos with strong username+pass
SSHauthentication is more common for internal projects where you can authenticate with a ssh-key-file and simple pass-phrase
GitLabusers are more likely to use the SSHprotocol

HTTP(S)协议通常用于具有强用户名+pass 的公共存储库
SSH身份验证更常见于内部项目,您可以使用 ssh-key-file 和简单的密码短语进行身份验证
GitLab用户更有可能使用SSH协议

View your remote info with

查看您的远程信息

git remote -v

If you see HTTP(S)address, this is the command to change it to SSH:

如果您看到HTTP(S)地址,这是将其更改为SSH的命令:

git remote set-url origin [email protected]_domain.com/example-project.git

回答by mawl

The Solution from https://github.com/gitlabhq/gitlab-shell/issues/46worked for me.

来自https://github.com/gitlabhq/gitlab-shell/issues/46的解决方案对我有用。

By setting the permissions:

通过设置权限:

chmod 700 /home/git/.ssh
chmod 600 /home/git/.ssh/authorized_keys

password prompt disappears.

密码提示消失。

回答by Ted C

I had this same problem when using a key of 4096 bits:

使用 4096 位密钥时,我遇到了同样的问题:

$ ssh-keygen -t rsa -C "GitLab" -b 4096
$ ssh -vT git@gitlabhost
...
debug1: Offering public key: /home/user/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/user/.ssh/id_dsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Next authentication method: password
git@gitlabhost's password:
Connection closed by host

$ ssh-keygen -t rsa -C "GitLab" -b 4096
$ ssh -vT git@gitlabhost
...
debug1:提供公钥:/home/user/.ssh/id_rsa
debug1:可以继续的身份验证:publickey,password
debug1:尝试私钥:/home/user/.ssh/id_dsa
debug1:尝试私钥:/home/user/.ssh/id_ecdsa
debug1:下一个身份验证方法:密码
git@gitlabhost 的密码:
连接被主机关闭

But with the 2048 bit key (the default size), ssh connects to gitlab without prompting for a password (after adding the new pub key to the user's gitlab ssh keys)

但是使用 2048 位密钥(默认大小),ssh 连接到 gitlab 时不会提示输入密码(在将新的 pub 密钥添加到用户的 gitlab ssh 密钥后)

$ ssh-keygen -t rsa -C "GitLab"
$ ssh -vT git@gitlabhost
Welcome to GitLab, Joe User!

$ ssh-keygen -t rsa -C "GitLab"
$ ssh -vT git@gitlabhost
欢迎来到 GitLab,Joe 用户!

回答by SensorSmith

This can happen if the host has a '-' in its name. (Even though this is legal according to RFC 952.) (Tested using Git Bash under Windows 10 using git 2.13.2.)

如果主机名称中有“-”,就会发生这种情况。(即使根据RFC 952这是合法的。)(使用 git 2.13.2 在 Windows 10 下使用 Git Bash 进行测试。)

ssh prompts me for a password for any host that happens to have a '-' in its name. This would seem to be purely a problem with ssh configuration file parsing because adding an alias to ~/.ssh/config (and using that alias in my git remote urls) resolved the problem.

ssh 会提示我输入名称中碰巧带有“-”的任何主机的密码。这似乎纯粹是 ssh 配置文件解析的问题,因为向 ~/.ssh/config 添加别名(并在我的 git 远程 URL 中使用该别名)解决了该问题。

In other words try putting something like the following in your C:/Users/{username}/.ssh/config

换句话说,尝试在您的 C:/Users/{username}/.ssh/config 中放置类似以下内容

Host {a}
    User git
    Hostname {a-b.domain}
    IdentityFile C:/Users/{username}/.ssh/id_rsa

and where you have a remote of the form

以及你有表格遥控器的地方

origin  [email protected]:repo-name.git

change the url to use the following the form

更改 url 以使用以下表单

git remote set-url origin git@a:repo-name.git

回答by Kurt

My problem was that I had a DNS entry for gitlab.example.comto point to my load balancer. So when I tried command ssh [email protected]I was really connecting to the wrong machine.

我的问题是我有一个gitlab.example.com指向我的负载均衡器的 DNS 条目。所以当我尝试命令时,ssh [email protected]我真的连接到了错误的机器。

I made an entry in my ~/.ssh/configfile:

我在我的~/.ssh/config文件中做了一个条目:

Host gitlab.example.com
    Hostname 192.168.1.50

That wasted a lot of time...

浪费了很多时间...

回答by foz

To add yet another reason to the list ... in my case I found this problem was being caused by an SELinux permissions problem on the server. This is worth checking if your server is running Fedora / CentOS / Red Hat. To test this scenario you can run:

在列表中添加另一个原因......在我的情况下,我发现这个问题是由服务器上的 SELinux 权限问题引起的。这值得检查您的服务器是否运行 Fedora / CentOS / Red Hat。要测试此场景,您可以运行:

Client: ssh -vT git@<gitlab-server>-- asks for password
Server: sudo setenforce 0
Client: ssh -vT git@<gitlab-server>-- succeeds
Server: sudo setenforce 1

客户端:ssh -vT git@<gitlab-server>——要求输入密码
服务器sudo setenforce 0
客户端:ssh -vT git@<gitlab-server>——成功
服务器sudo setenforce 1

In my case the gitlab/git user's authorized_keysfile had the wrong SELinux file context, and the ssh service was being denied permission to read it. I fixed this on the server side as follows:

在我的例子中,gitlab/git 用户的authorized_keys文件有错误的 SELinux 文件上下文,并且 ssh 服务被拒绝读取它的权限。我在服务器端修复了这个问题,如下所示:

sudo semanage fcontext -a -t ssh_home_t /gitlab/.ssh/
sudo semanage fcontext -a -t ssh_home_t /gitlab/.ssh/authorized_keys
sudo restorecon -F -Rv /gitlab/.ssh/

And I was then able to git cloneon the client side as expected.

然后我就可以git clone按预期在客户端了。

回答by MakisH

In my case, I was using a pair of keys that didn't have the default names id_rsaand id_rsa.pub.

就我而言,我使用了一对没有默认名称id_rsaid_rsa.pub.

Producing keys with these names solved the problem, and I actually found it looking at the output of ssh -vT my_gitlab_address. Strange fact: it worked on one computer with Ubuntu, but not on others with different distributions and older versions of OpenSSH.

使用这些名称生成密钥解决了这个问题,我实际上发现它正在查看ssh -vT my_gitlab_address. 奇怪的事实:它可以在一台装有 Ubuntu 的计算机上运行,​​但不能在具有不同发行版和旧版本 OpenSSH 的其他计算机上运行。

回答by zxhralf

I am using a mac.gitlabis installed in a centos server.

我正在使用mac.gitlab安装在 centos 服务器中。

I have tried all the methods above and found the final answer for me:

我已经尝试了上述所有方法,并为我找到了最终答案:

wrong:

错误的:

ssh-keygen -t rsa

right:

对:

 ssh-keygen -t rsa -C "[email protected]" -b 4096

回答by Bruce

On Windows 10 using the terminal under VS Code I got a prompt for "git@gitlab's password:" when trying to:

在使用 VS Code 下的终端的 Windows 10 上,当我尝试执行以下操作时,我收到了“git@gitlab 的密码:”提示:

git push -u origin --all

I had established my ssh credentials in windows and in gitlab but I had used Windows 10 bash key-gen to do so. The solution then was to invoke bash in VS code terminal and then issue the command again.

我已经在 Windows 和 gitlab 中建立了我的 ssh 凭据,但我使用了 Windows 10 bash key-gen 来这样做。解决方案是在 VS 代码终端中调用 bash,然后再次发出命令。

bash
git push -u origin --all

It succeeded.

它成功了。

To avoid having to use bash/git manually, I then put a symlink between the windows .ssh/id_rsa and the bash shell .ssh/id_rsa:

为了避免手动使用 bash/git,我在 windows .ssh/id_rsa 和 bash shell .ssh/id_rsa 之间放置了一个符号链接:

C:\Users\bruce\.ssh>mklink id_rsa C:\Users\bruce\AppData\Local\lxss\home\bruce\.ssh\id_rsa

VS Code Git menu actions (push, pull, etc.) now worked with gitlab

VS Code Git 菜单操作(推、拉等)现在可与 gitlab 一起使用