Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have two machines both running CentOS linux, one is public facing machine with a real ip address (foo). The other is at a client's site behind a very restrictive firewall and with no real ip and no possibility of natting or opening an port to it (bar).

I can ssh from bar to foo, however obviously not the other way round.

Ideally I would like to be able to ssh from foo to bar so I am able to send file, work remotely, etc. Would really appreciate any help or advice on how best to get this working, have seen various tutorials on the internet which suggest it should be possible to setup a VPN connection over ssh but can't quite seem to figure it out.

Jona

share|improve this question

5 Answers 5

up vote 2 down vote accepted

Under Centos the answer appears to be as follows:

on bar (the restricted machine) run the following command:

ssh -N -R 1234:localhost:22 foo.theinternet.com

then on foo (the open machine) run:

ssh -p 1234 localhost

I suspect there are refinements to be made to this, but hopefully it will be enough to get any googlers started.

Thanks to pkaeding for putting me on the right track.

share|improve this answer

This ought to do it for you (from bar):

ssh -R2222:localhost:22 foo

Then, on foo:

ssh localhost -p 2222

The first connection opens a remote port forward, which makes port 2222 on foo forwarded to port 22 on bar. So, if you ssh to port 2222 on foo, you are really connecting to bar. You can then add whatever forwards you need to through that ssh connection, to forward any other ports.

share|improve this answer
    
Hi there, this is exactly what I want to do however these specific syntax don't seem to work. One difference I notice is that I need to use ssh -p 2222 localhost. But obviously something else isn't working as this command outputs connection refused. –  Jona Sep 21 '09 at 16:55
    
Oops, yeah I made a mistake with the syntax. I fixed it now. Do you see anything interesting in in the ssh session on bar? You can get information about open connections by hitting <enter>~# (in sequence, not at the same time). Does that give back anything interesting? –  pkaeding Sep 22 '09 at 3:04

You can create tun device, that is a full tunnel. Requirements are: probably root access in both client and server, and recent versions of SSH.

server /etc/ssh/sshd_config

PermitRootLogin yes PermitTunnel yes

client /etc/ssh/ssh_config

Tunnel yes

Connect with: ssh -w any:any ...

That will create a tun0 device on both client and server. You must set up IP:

server

ifconfig tun0 192.168.55.1 pointopoint 192.168.55.2

client

ifconfig tun0 192.168.55.2 pointopoint 192.168.55.1

Now routes, NAT, whatever...

Anyway i wouldn't recommend this method for connecting from bar to foo automatically, ie. in a non-interactive fashion. If the TCP session dies it won't respawn automatically. Well, maybe you can make it respawn: http://www.deer-run.com/~hal/sysadmin/SSH-SyslogNG.html

There should be a way to create a VPN between the two hosts, not neccesarily based on SSH.

share|improve this answer
    
Will this work when one of the machines is private so I can only ssh in one direction? –  Jona Sep 22 '09 at 21:15

There are several options and lots of answers can be found on this site if you search. You can forward ports. You can use ssh as a socks proxy. Or you can actually tunnel ip over ssh using something like ppp.

share|improve this answer

Sounds like you are looking for something that works like Wippien or Remobo, which are inspired by the costly Hamachi client.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.