Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git clone requires ssh:// protocol when perhaps it shouldn't?

Tags:

git

ssh

A colleague of mine has a remote git repo that I wanted to clone and he provided a url of [email protected]:443/repo.git. ssh is listing on port 443 in this case.

I tried to clone by doing git clone [email protected]:443/repo.git but the operation times out. I had thought git defaults to ssh as its protocol and I'm not sure why this does not work.

If I explicitly specify ssh in the url like git clone ssh://[email protected]:443/repo.git it works just as normal.

Is that expected git behavior? Why does the first url not work but the second one does?

like image 587
whaley Avatar asked Jul 29 '10 20:07

whaley


People also ask

Do you need an ssh key to clone a repo?

Git will need a ssh key only if you are using ssh protocol - there doesn't exist such a thing as anonymous ssh, ssh needs a key (an account) to work. If you use git or https protocol, no ssh key is needed.

What protocol does Git clone use?

The SSH Protocol Probably the most common transport protocol for Git is SSH. This is because SSH access to servers is already set up in most places — and if it isn't, it's easy to do. SSH is also the only network-based protocol that you can easily read from and write to.

What is the difference in Git clone by ssh and HTTPS?

The difference is in the protocol used, as you probably guessed. Assuming you don't much care about the technical details between HTTPS and ssh, ssh has the advantage that you can use public key authentication, while you must use a username and password with HTTPS.

Is Git using ssh or HTTPS?

The default on both GitHub.com (the website) and in GitHub CLI is using the HTTPS protocol for git operations. This default was chosen for interoperability and ease of use: Git users who are behind firewalls find that traffic to port 443 (HTTPS) is more often allowed than traffic to port 22 (SSH).


1 Answers

Yeah. The "default" clone syntax is scp-like. scp URLs look like "user@host:path". Note the colon; if you use [email protected]:443/repo.git, Git thinks you're trying to clone a path 443/repo.git from [email protected]. If you need to specify a port, you have to use the ssh-style syntax (as you ended up doing).

like image 125
mipadi Avatar answered Oct 21 '22 07:10

mipadi