GitLab git user password

匿名 (未验证) 提交于 2019-12-03 02:14:01

问题:

I have just installed GitLab.

I created a project called project-x.

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

Now I tried to clone:

 git clone git@192.168.0.108:project-x.git 

It prompted me for a password.

What password should I use?

回答1:

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.

But that supposes that ssh -vT git@192.168.0.108 is working first.



回答2:

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)

view your remote info with

git remote -v 

if it is with HTTP address, this is the command to change it:

 git remote set-url origin git@gitlab.my_domain.com/exmaple-project.git 


回答3:

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

By setting the permissions:

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

password prompt disappears.



回答4:

I had the right public/private key, but seemed like it didn't work anyway (got same errors, prompting for the git-user password). After a computer-restart it worked though!



回答5:

In my case, I was using a pair of keys that didn't have the default names id_rsa and id_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.



回答6:

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

$ 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

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)

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



回答7:

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.)

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.

In other words try putting something like the following in your 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  git@a-b.domain:repo-name.git 

remove it and then re-add it using the form

origin  git@a:repo-name.git 


回答8:

The same solution for Windows machine:

  1. Generate SSH key and add key to Git lab server
  2. Make sure 2 SSH key files are in /.ssh folder (e.g C:\Users\xxx.ssh)

Clone should be successful without password require.



回答9:

I had the same problem, I spent a lot of time searching!

I had the idea to use Eclipse to import the project from GitLab.

Once the project is imported correctly, I made the comparison between the configuration of :

  • the project's Git ripository that I imported into Eclispe, ("in Eclipse", Git Repository, in myprojectRepo / Working Directory / .git / config)
  • the one that is made in .git / config, there i wanted to push my project with git: git push ... and asked me for a password.

Surprise: The remote does not have the same in both cases. I handed the same as that in eclipse and everything works.



回答10:

Had the same problem in Windows 10 (don't know if this is relevant). Had everything set up correctly, the ssh -vT git@myserver command succeeded, but Gitlab still asked for my password.

Removing then re-creating the key in Gitlab was the trick for me.



回答11:

On my Windows 10 machine it was because the SSH_GIT environment variable wasn't set to use the putty plink I had installed on my machine.



回答12:

You may usually if you have multiple keys setup via ssh on your system (my device is running Windows 10), you will encounter this issue, the fix is to:

Precondition: Setup up your SSH Keys as indicated by GitLab

  1. open /c/Users//.ssh/config file with Notepad++ or your favourite editor
  2. paste the following inside it. Host IdentityFile ~/.ssh/

Please note, there is a space before the second line, very important to avoid this solution not working.



回答13:

I am using a mac.gitlab is installed in a centos server.

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 "your.email@example.com" -b 4096 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!