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?

2
  • 2
    If you have access to a second, world-facing server, you can set up a reverse tunnel
    – ernie
    Commented Oct 3, 2013 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? Commented Oct 3, 2013 at 23:45

2 Answers 2

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.

3
  • 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: quantumg.net/portforward.php . Anyway, my method could also be useful in some cases. Commented Feb 24, 2014 at 12:31
  • 2
    Any reliable method for keeping the reverse session alive?
    – Ashley
    Commented Jan 27, 2015 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
    Commented Aug 31, 2020 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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .