7

I have a computer at home with SSH installed which I would like to be able to control remotely. However, I am not able to allow SSH port forwarding through my router, so the only way to get in would be to have the installation on my computer listen to a port on a server for connections. Is there any existing software for this purpose?

danielmhanover
  • 247
  • 3
  • 10
  • 2
    If you have access to a second, world-facing server, you can set up a reverse tunnel – ernie Oct 03 '13 at 23:34
  • I do have access to a public server. If I set up a reverse tunnel, would the world-facing server need to be able to connect to the computer? – danielmhanover Oct 03 '13 at 23:45

2 Answers2

6

As you mention having access to an outside server, you should be able to do this via reverse tunnel.

From your home system, you'll want to ssh to the remote server, with syntax like:

ssh -g -R 12345:localhost:22 user@remoteserver
  • the -g flag allows remote hosts to connect to the forwarded port. Otherwise, the default ssh setting is that only the system that first made the tunnel could use the port (meaning the home server)
  • -R is used to set up the reverse tunnel, and we're saying that connections to remoteserver:12345 should be forwarded to localhost:22

To use the tunnel, you'd do something like:

ssh -p 12345 remoteserver

Of course, for this tunnel to work, you'll need to ensure that the ssh session from homeserver to remoteserver stays alive.

ernie
  • 6,293
  • 2
  • 28
  • 30
  • 1
    Thanks @ernie, for the "-g" info. I didn't know, so until now I was using a port forwarder program constantly running on the server. A simple one that can be found here: http://www.quantumg.net/portforward.php . Anyway, my method could also be useful in some cases. – Sopalajo de Arrierez Feb 24 '14 at 12:31
  • 2
    Any reliable method for keeping the reverse session alive? – Ashley Jan 27 '15 at 16:27
  • @Ashley You and others looking for a way of keeping the session alive should look into autossh, which handles reconnecting, etc. – oligofren Aug 31 '20 at 18:16
1

@Ashley Steel, look at setting the value of ServerAliveInterval to a non-zero value. On the ssh commandline, that would be something like this: -oServerAliveInterval\ 60

You could also configure it in the .ssh/config file by remote host.

Yedric
  • 719
  • 4
  • 11