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:
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
change the url to use the following the form
git remote set-url origin git@a:repo-name.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.
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.
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.
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!
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