Zac
Zac

Reputation: 2081

ssh git clone times out

Please help

I'm attempting to communicate with git / github on a linux ubuntu server via SSH while also having a different port for SSH ( not 22 ). When I attempt to git clone, I am using this command:

$ git clone -v [[email protected]:12345]:username/project-web.git myfolder

It hangs for about 3 minutes then I get this output:

Cloning into 'myfolder'...
ssh: connect to host github.com port 12345: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have my firewall ( UFW ) setup correctly; I can successfully SSH and connect to the server. This is my UFW configuration:

22                         DENY        Anywhere
12345/tcp                  ALLOW       Anywhere
12345                      ALLOW       Anywhere
22/tcp                     DENY        Anywhere
22 (v6)                    DENY        Anywhere (v6)
12345/tcp (v6)             ALLOW       Anywhere (v6)
12345 (v6)                 ALLOW       Anywhere (v6)
22/tcp (v6)                DENY        Anywhere (v6)

And this is my ~/.ssh/config file:

Host github.com
    User git
    Hostname github.com
    IdentityFile ~/.ssh/deploy
    IdentitiesOnly yes
    Port 12345

and my /etc/ssh/sshd_config file:

...
Port 12345
...

I've tried these other related SO answers and still no luck:

git remote add with other SSH port

Git On Custom SSH Port

What am I doing wrong? Am i using the wrong command? I've tried many of the commands in the related answers above, still no luck.

Upvotes: 1

Views: 2874

Answers (2)

Jiri Kremser
Jiri Kremser

Reputation: 12837

In short you can't change the port on which the remote service is listening. You are trying to use non-default port 12345 with github.com This is not going to fly. Also changing stuff in /etc/ssh/sshd_config is totally irrelevant here. It changes the behavior of your sshd (i.e. if someone tries to ssh or git@ssh to your machine).

Btw. you can test your ssh connection to github w/ this one-liner:

ssh -T [email protected]

Note that any non-default port will hang the connection (ssh -T [email protected] -p 12345)

Upvotes: 2

VonC
VonC

Reputation: 1323953

First, if you want your ~/.ssh/config to be taken into account, your SSH URL should be

github.com:username/project-web.git

(no git@, no :12345)

Second 12345 would only work with a reverse proxy, which would then redirect to port 22 or 443 (when "Using SSH over the HTTPS port").
Regarding port 443, the Hostname would then be ssh.github.com.

Upvotes: 1

Related Questions