Different SSH Path Problem

Greetings. I am a new gitlab administrator. I have successfully installed gitlab and imported repositories. However, I’m experiencing a strange problem that I couldn’t find a solution to despite hours of searching. I would appreciate if someone could point me in the right direction.

Cloning repositories via HTTP works normally, but SSH does not. I am able to connect and gitlab-shell runs normally. My user is properly authenticated. The gitlab “check” does not show any errors. Permissions are correct. However, the path does not work as expected. See below.

Does NOT Work
git clone ssh://git@gitlab.domain.com:group/project.git
The project you were looking for could not be found.
gitlab-shell: Access denied for git command git-upload-pack ‘/project.git’ by user with key key-2.

Clones Successfully
git clone ssh://git@gitlab.domain.com:group/group/project.git
gitlab-shell: executing git command git-upload-pack /var/opt/gitlab/git-data/repositories/group/project.git for user with key key-2.

As you can see, adding an extra group directory in the path (that does not exist) allows the clone to succeed. I have verified that the correct path is actually being supplied to gitlab-shell via SSH in verbose mode. I’m sure there is some simple configuration I’m missing. If it makes a difference, I am using Apache instead of nginx. Any ideas? Thanks!

I finally figured out my problem. I hope this post helps someone in the future.

When using git’s SSH URL format with gitlab, the first argument after the colon (before slash) seems to be treated as the port. Therefore, it gets stripped from the request to/by gitlab-shell. Use the git SCP syntax instead:

git clone git@gitlab.domain.com:group/project.git
(without ssh://)

Actually, the standard practice with git clone is not to use ssh://. Git defaults to using SSH if you do not specify a protocol.

Both GitLab and GitHub give you the complete clone URLs for SSH and HTTP(S) on each project’s homepage, and neither one tells you to use the protocol at the front of the URL for SSH cloning, only for the HTTP(S) cloning.

Yes, I finally figured that out. I knew I was overlooking something simple. Thanks.

We always patch our installation to show the correct syntax including ssh:// see the GIT URLS section at https://www.kernel.org/pub/software/scm/git/docs/git-clone.html as well.
The syntax without the prefix is only.mentioned as “alternative scp syntax”. If your group name includes a digit tools like Maven will choke with the scp syntac because the group is misinterpreted as port. The complete syntax is much more stable. We are filed a MR more than a year ago.