Proxy everything with ssh

So sometimes you need to access some isolated system from remote but the only way to talk to the system is through another system to which you only have ssh access on one port.

It turns out that this isn't a problem at all since the only thing you require to access a foreign system through an intermediary system is ssh.

The following one liner allows just this:

    ssh -N -L LOCAL_PORT:target.domain.tld:TARGET_PORT USER_NAME@proxy.server.host.tld

Command Explanation:

  • -N is the ssh no command flag. It means that no command should be executed uppon connection. This has as a side effect that You will not get a normal shell after connection. Instead the ssh process will block the terminal until it times out or you exit with CTRL + c.
  • -L is the port forwarding directive the complete syntax is [bind_address:]local_port:target_host:target_port in short this means that the port local_port will be routed to target_port on target_host.
  • The last argument is the standard ssh user@hostname argument.

As always much more in depth information can be had via man ssh so go there in case You want to learn the inner workings of ssh.