简体   繁体   中英

Unable to clone git via SSH Tunnel

TLDR

I am trying to ssh tunnel in from my linux machine into a OSx machine that has access to my VPN. This is the URL that I need access github.someprivateurl.net .

The actual problem in details.

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/Mortgages/mortgages.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/Mortgages/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.

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

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

Update

As this is I believe just a SSH error. I should mention, that the SSh is actually through Host to guest SSH. My guest has a host-only connection and is connected to the internet via its own physical wifi dongle. Its the wifi connection that the VPN is setup.


hutber@hutber ~ $ ssh -fNT -L 3333:github.someprivateurl.net:22 hutber@192.168.1.18
Password:
hutber@hutber /var/www $ ssh -p 3333 github.someprivateurl.net
^C //Hangs
hutber@hutber /var/www $ telnet localhost 3333
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
SSH-2.0-libssh_0.7.0
^^
Connection closed by foreign host.

$ ping -p 3333 github.someprivateurl.net

-p does not mean the port to ping. It means... something else. So that's not checking if port 3333 is open, you're just pinging the machine in a weird way.

Your git ssh URL is incorrect. Rather than using port 3333 on the remote host you're tunneling to, you have to tell it to use localhost's port 3333.

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

As with most git+ssh problems, it's easiest to debug them as ssh problems. First is to actually try sshing to port 3333.

ssh -p 3333 localhost

I suspect that's not going to work. From there, debug the ssh problem normally.

I suspect your tunnel is not actually running because your tunnel shut down as soon as you logged out of the ssh session it opened. You need some extra flags to make it persist as a tunnel. Specifically...

  • -f to tell ssh to go to the background immediately
  • -N to stop it from trying to execute a remote command
  • -T to not allocate a pseudo-terminal do handle typing

So that's...

ssh -fNT -L 3333:github.someprivateurl.net:22 hutber@192.168.1.18

You'll also want to look into using autossh to keep the connection up for you.

edit: i accidentally missed a part of the question, so this does not apply.

-Try replacing git protocol with https .

-Download the zip on your local machine and scp it to your server.

-Remove the tunnel. doesnt make sense either. You could just ssh into it. Or setup the vpn from your current machine. That's what's vpn is for.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM