Task: ssh Tunnel to a Hub

Sometimes for one reason or another you might want to access a hub running on machine A from machine B, but cannot do so directly. For example, it may be the case that:

An ssh tunnel can provide a connection path from B to A with the encryption and authentication facilities of ssh, provided that an ssh daemon is running on A or some machine C with direct network access to A. Note that all users on B will have access to the hub, not just the user who created the ssh tunnel.



Set Up an ssh Tunnel

The method for setting up an ssh tunnel from B to A depends on whether or not A is running an ssh daemon.

If A is running an ssh daemon:

  1. Check: is a hub already running at location A?
  2. At location B, map local port Bport to the hub port with an ssh command:
    ssh -LBport:[::1]:hubport A
  3. Now use [::1]:Bport on B to access the hub:

If A is not running an ssh daemon, but some machine C with unrestricted network access to A is running an ssh daemon:

  1. Check: is a hub already running at location A?
  2. At location B, map local port Bport to the hub port with an ssh command:
    ssh -LBport:A:hubport C
  3. Now use [::1]:Bport on B to access the hub:

IPv4 Note

If your system does not support IPv6 addresses, use IPv4 to specify addresses instead.

Links