Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Clone: Illegal Port Number

I'm trying clone a repository with http using the username and password lik e this:

git clone https://username:[email protected]/user/repo.git

However I get this error:

fatal: unable to access 'https://username:[email protected]/user/repo.git': Illegal port number

I'm trying to do this on a EC2 Instance that is using AWS Linux. I can get this working if I do it manually, and use only the username in the clone and then put the password to the prompt, but I'm trying to clone the repository with a bash script.

like image 691
Miika Avatar asked Jan 12 '18 20:01

Miika


People also ask

What port does Git use?

The native git transport uses TCP port 9418. However, git can also run over ssh (often used for pushing), http, https, and less often others. You can look at the repository URL to find out which port it uses.

How does Git clone work on local machine?

When the repository to clone from is on a local machine, this flag bypasses the normal "Git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories. The files under .git/objects/ directory are hardlinked to save space when possible.

How do I view Git connections through the firewall?

See the git fetch manpage for more details on the available URL schemes. Git uses port 9418. You can view connections using that port with. Open 9418 and your traffic will pass through the firewall. I've also found that the outbound SSH port 22 might need to be open as well as port 9418 for Git (both TCP).

How does the Git clone flag work?

When the repository to clone from is on a local machine, this flag bypasses the normal "Git aware" transport mechanism and clones the repository by making a copy of HEAD and everything under objects and refs directories.


1 Answers

With Charles' comments I figured out the reason why this error occurred. The password contained a %-character and a 4-character, which is the URL Encoded value of @-character. This caused it treat it as a proxy password (if I understood correctly.. basically the solution here.)

So what I did was I changed the password, and now it works just fine!

like image 98
Miika Avatar answered Sep 28 '22 02:09

Miika