Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gitlab can't clone repository even though ssh works

Tags:

git

ssh

gitlab

As the title states, I can't clone a repository from a Gitlab 6 server even though the ssh seems to work.

When trying to clone, it looks like this:

git clone ssh://[email protected]:1337/project/repository.git
Cloning into 'repository'...
Access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

In the project, I have the role of "developer" which should have the rights to clone a repository?

I also checked if my SSH public key is working

ssh [email protected] -p 1337 -T
Welcome to GitLab, Anonymous!

More irritating to me is that for a friend of mine seems everything to work fine.

Edit: The main indicator for the problem stated here is the greeting from the SSH Test. In an working enviroment it should be greeting you with your name instead Anonymous!

like image 605
Felix Avatar asked Nov 20 '15 22:11

Felix


People also ask

Why git clone is not working?

If you have a problem cloning a repository, or using it once it has been created, check the following: Ensure that the user has gone through initial GitCentric login and has the correct username, email, and ssh. This should return a usage message that refers to the config-branch, config-repo, and ls-repo commands.

How do I clone a git repository without SSH?

If you need to clone a private GitHub repository without an SSH key you can use a Personal Access Token. This can be useful in a build/deployment pipeline for example where you are using a programmatic GitHub user to clone into a temporary server or container.


1 Answers

Try the scp-like syntax:

git clone ssh://[email protected]:1337:project/repository.git

That forces the use of ~/.ssh/config actually, which means the url can be simplified to gitlab:project/repositoriy.git.

But it turned out to be an ssh key issue in the gitlab server ~gitlab/.ssh/authorized_keys (a bit like in issue 4730).
The OP Gelix confirms in the comments:

I removed my key from Gitlab, manually from authorized_keys, readded it on Gitlab. Everything fine now.
Message with SSH Test is now also Welcome to GitLab, Felix *****!

(instead of Welcome to GitLab, Anonymous!)

like image 188
VonC Avatar answered Sep 23 '22 11:09

VonC