Any idea why a GIT repo would work only when using ssh://git@server.com/repo.git and not also when using git@server.com/repo.git?

It's a server setup by someone else so no idea how it was setup but on BitBucket or GitHub I can just use git@server.com/repo.git and it works and clones the repo using SSH protocol. Any idea why for this server iy only works when using ssh://git@server.com/repo.git ?

So i need to add the ssh:// in front.

  • Does the server use an alternative SSH port? Like ssh://git@server.com:2222/ – 7ochem Apr 10 '18 at 12:32
  • No. It's 22. As ssh://git@server.com/repo.git works while git@server.com/repo.git doesn't. I'm not adding the :port in any cases. When I try without ssh:// I get fatal: repository 'git@server.com/something/repo.git' does not exist. With ssh://git@server.com/something/repo.git it works. – daniels Apr 10 '18 at 12:41
  • A configuration issue of some sort (maybe a firewall? username issue?) - I have a similar problem with a setup at my institution. However access via https works - so the solution is to use the rewrite rules from this thread: stackoverflow.com/questions/15589682/… – DetlevCM Apr 10 '18 at 16:00

You are using the incorrect syntax.

When you remove the scheme:// prefix, git no longer interprets your address in URL style anymore, but instead as rcp/scp style. But for rcp/scp style addresses, the path must be separated from user@host using a colon : (specifying a port is not supported). For example:

git clone daniels@server.com:repo.git

git clone git@bitbucket.com:daniels/example.git

Without the colon, git will only interpret the address as a local path.

(You can see more details in the git clone or git fetch manual page.)

  • Hah, mystery solved. You are right. Thank you. – daniels Apr 10 '18 at 15:32
  • I was using BitBucket server (former Stash, the one you install on your server, not the cloud version) and just copy & pasted the GIT command from there. For some reason they don't add those missing :. – daniels Apr 10 '18 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.