GitLab git user password

GitGitlab

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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)

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

View your remote info with

git remote -v

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

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

Solution 2 - Git

> 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 [email protected] is working first.

Solution 3 - Git

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.

Solution 4 - Git

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!

Solution 5 - Git

This can happen if the host has a '-' in its name. (Even though this is legal according to [RFC 952][1].) (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

change the url to use the following the form

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

[1]: https://www.rfc-editor.org/rfc/rfc952 "RFC 952"

Solution 6 - Git

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

I made an entry in my ~/.ssh/config file:

Host gitlab.example.com
    Hostname 192.168.1.50

That wasted a lot of time...

Solution 7 - Git

After adding the new SSH Key in GitLab, check if you have "git" group included in SSHD AllowGroups (for Debian /etc/ssh/sshd_config). If not, add it and restart sshd (systemctl restart ssh).

Test it with ssh -vT [email protected] as suggested above.

Solution 8 - Git

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:

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

In my case the gitlab/git user's authorized_keys file 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:

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 clone on the client side as expected.

Solution 9 - Git

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!

Solution 10 - Git

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.

Solution 11 - Git

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.

Solution 12 - Git

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 "[email protected]" -b 4096

Solution 13 - Git

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

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.

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:

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

Solution 14 - Git

For my case, it turns out the gitlab was running in docker, and has port mapping 4022/22.

Thus I have to edit ~/.ssh/config to specify the port via Port 4022, e.g:

Host gitlab-local
    Hostname        192.168.1.101
    User git
    Port 4022
    IdentityFile    ~/.ssh/id_rsa.pub
    # LogLevel DEBUG3

Solution 15 - Git

When git clone asks for a password, there's probably a problem with your local machine. My problem was that I was using a custom path for saving the ssh key and that path wasn't visible to git. Either use the default path suggested to you or add the file in the custom location using ssh-add <file>

Solution 16 - Git

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.

Solution 17 - Git

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.

Solution 18 - Git

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.

Solution 19 - Git

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.

Solution 20 - Git

if you are sure that you have uploaded the content of key.pub into GitLab, then: 1- Open Git Bash "Not CMD" 2- Browse to Solution Folder "CD Path" 3- Type Git Init 4- Type Git Add . 4- Type Git Commit 6- Type Git Push

and it will work.. another hint: make sure the path of the file where you copied the key is correct and equivalent to the same path it showed on CMD when creating the keys

Solution 21 - Git

Just in case anyone had the same problem as mine. I was running the GitLab server in docker env and I wanted to set an ssh connection port as 2202, not 22 so I bonded the 2202 port of the host to 2202 port of the docker container. I didn't do it for 22.

And then I forgot that I had to change the default connection port of ssh ... So I had the same error as this question writer.

First, I opened port #22 and it worked, so after that, I changed the ssh connection port to 2202 it all worked fine.

It was stupid of myself but it might help other dummies :)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAlvinView Question on Stackoverflow
Solution 1 - Gitd.raevView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow
Solution 3 - GitmawlView Answer on Stackoverflow
Solution 4 - GitTed CView Answer on Stackoverflow
Solution 5 - GitSensorSmithView Answer on Stackoverflow
Solution 6 - GitKurtView Answer on Stackoverflow
Solution 7 - GitfvalverdView Answer on Stackoverflow
Solution 8 - GitfozView Answer on Stackoverflow
Solution 9 - GitAnigifView Answer on Stackoverflow
Solution 10 - GitMakisHView Answer on Stackoverflow
Solution 11 - GitVu NguyenView Answer on Stackoverflow
Solution 12 - GitzxhralfView Answer on Stackoverflow
Solution 13 - GitBruceView Answer on Stackoverflow
Solution 14 - GitEricView Answer on Stackoverflow
Solution 15 - GitBenjaminView Answer on Stackoverflow
Solution 16 - GitSofteng.mfView Answer on Stackoverflow
Solution 17 - GitJulienView Answer on Stackoverflow
Solution 18 - GitAlexView Answer on Stackoverflow
Solution 19 - GitOkyere Adu-GyamfiView Answer on Stackoverflow
Solution 20 - GittheKView Answer on Stackoverflow
Solution 21 - GitSunyoung LuyView Answer on Stackoverflow