Setting Up Port Forwarding


You may wish to run processes on your local machine that connect to the cluster, doing this directly can be difficult because of the requirement of  2 jumps and Second Factor Authentication.

A simpler method is to set up port forwarding.

Three values must be provided, the local port, the host alias, and the remote port. Chosen port numbers should be between 1024 and 49151 and not be in use by another process.

Local Port: Any process connecting to 127.0. 0.1:<local port> on your local will be forwarded to the remote (in this case, the NeSI cluster).

Host Alias: An alias for the socket of your main connection to the cluster, mahuika or maui if you have set up your ssh config file as described here.

Remote Port: Any process connecting to 127.0. 0.1:<remote port> on your remote will be forwarded to your local.

SSH config (Linux/MacOS/WSL)

If setting up your connection to the cluster required the creation of a ssh config file, port forwarding can be set up by modifying this.

Under the alias for the cluster you want to connect to add the following lines.

LocalForward <local port> <host alias>:<remote port>
ExitOnForwardFailure yes

ExitOnForwardFailure is optional, but it is useful to kill the session if the port fails. 


  Host mahuika
      User cwal219
      ProxyCommand ssh -W %h:%p lander
      ForwardX11 yes
      ForwardX11Trusted yes
      ServerAliveInterval 300
      ServerAliveCountMax 2
      LocalForward 6676 mahuika:6676
ExitOnForwardFailure yes

In the above example the local and remote ports are the same, this isn't a requirement it just makes things easier to remember.

Now, provided you have an regular ssh session open, any local process needing access to the cluster can simply point to 127.0. 0.1:6667 


  • If you get a error message
    bind: No such file or directory
    unix_listener: cannot bind to path: 
    try to create the following directory:
    mkdir -P ~/.ssh/sockets



  • MobaXterm has an internal terminal which acts like a linux terminal and can be configured as described in the Standard Terminal Setup

MobaXterm has a GUI to setup and launch sessions with port forwarding, click 'Tools > MobaSSH Tunnel (port forwarding)':

  • specify the as SSH server address (right, lower box, first line)
  • specify your user name (right, lower box, second line)
  • specify the remote server address, e.g.  (right, upper box first line)
  •  and at the remote server (right upper box, second line)
  • Specify the local port number on the local side (left)
  • Save



Coming soon..



What Next?

Was this article helpful?
0 out of 0 found this helpful