SSH Tunnel Connected but Can’t Git Clone – Solutions

gitmac-osxsshssh-tunnel

I believe this is a fairly simple one, but on the face of things I am sure its not "wrong".

I am trying to ssh tunnel in from my linux machine into a OSx machine that has access to my VPN.

Setting up tunnel

hutber@hutber ~ $ ssh -L 3333:github.someprivateurl.net:22 hutber@192.168.1.18
Password:
Last login: Thu Jun  7 01:00:34 2018 from 192.168.1.3
hutber@Jamies-Mac ~ $ 
hutber@Jamies-Mac ~/www/jamie $ git clone ssh://git@github.someprivateurl.net/POC05Mortgages/mortgages-ui.git
Cloning into 'mortgages-ui'...
remote: Counting objects: 63823, done.
remote: Compressing objects: 100% (52/52), done.
^Cfatal: The remote end hung up unexpectedlyMiB | 8.44 MiB/s  

^ is just to show that when ssh'd into the OSx I am able to clone within this machine.

Accessing the tunnel

hutber@hutber /var/www $ git clone ssh://git@github.someprivateurl.net:3333/POC05Mortgages/mortgages-ui.git


Cloning into 'mortgages-ui'... 

The above clone on my linux machine will hang until the connection realises it doesn't have access and throws me out.

How can I clone the repo on my linux machine whilst ssh'd into OSx?

Edit

I'm not sure how helpful this is… But I am unable to reach the site I am trying to clone, so its obviously nothing to do with git:

OSx

hutber@Jamies-Mac ~/www/jamie $ ping github.someprivateurl.net
PING github.someprivateurl.net (10.113.188.195): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
^Z
[1]+  Stopped                 ping github.someprivateurl.net

Linux

hutber@hutber /var/www $ ping -p 3333 github.someprivateurl.net
PATTERN: 0x3333
PING github.someprivateurl.net (159.34.88.181) 56(84) bytes of data.
From 172.16.24.82 icmp_seq=1 Time to live exceeded
From 172.16.24.82 icmp_seq=2 Time to live exceeded
From 172.16.24.82 icmp_seq=3 Time to live exceeded
From 172.16.24.82 icmp_seq=4 Time to live exceeded
^C
--- github.someprivateurl.net ping statistics ---
4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3004ms

Best Answer

When you set up an SSH tunnel, you're specifying that connections to the specified port on the local host are to be forwarded to the specified remote host and port via the SSH server to which you're connecting. So to use the tunnel, you have to send traffic to localhost:port. In your case, if I'm reading the outputs of your commands correctly, it should be as simple as:

git clone ssh://git@localhost:3333/POC05Mortgages/mortgages-ui.git

Assuming the tunnel is set up, of course.

I wouldn't worry too much about the ping failures. A lot of machines or networks are configured to reject ICMP traffic even if they accept other traffic. In situations where you're unsure, it's often useful to use a tool like tcptraceroute or hping that can run network diagnostics using TCP instead of ICMP.

Incidentally, there's a public IP listed in the ping output from your Linux machine. You might want to redact that.

Related Topic