Git clone only works with ssh://git@.. and not with git@

11

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.

daniels

Posted 2018-04-10T12:21:14.190

Reputation: 291

Does the server use an alternative SSH port? Like ssh://git@server.com:2222/ – 7ochem – 2018-04-10T12:32:26.517

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 – 2018-04-10T12:41:57.993

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: https://stackoverflow.com/questions/15589682/ssh-connect-to-host-github-com-port-22-connection-timed-out

– DetlevCM – 2018-04-10T16:00:31.697

Answers

32

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.)

user1686

Posted 2018-04-10T12:21:14.190

Reputation: 283 655

Hah, mystery solved. You are right. Thank you. – daniels – 2018-04-10T15:32:29.030

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 – 2018-04-10T15:33:55.123