SSH Port Fowarding Tunnels
The other day I needed to set up a
Syncthing instance on a
remotely networked server that had no graphical display. I didn’t want to set it
up using the command line tools and I definitely did not want to install a
graphical environment on the server to access the web GUI
.
There is another computer with a graphical display on the local network. The
only problem is that a standard syncthing
installation does not have its port
(8384
) exposed to computers on the local network. We would be unable to access
the web server.
This means that one would need to expose that port either by configuring
syncthing
directly or by opening up the respective port. That direction is
more involved. There is a great solution to this problem and it’s called SSH
port forwarding. The solution comes down to this single command.
shell
ssh -v -NL 12345:127.0.0.1:8384 machine.remote
The above command states that it will forward or bind port 8384
of 127.0.0.1
(syncthing
) from machine.remote
to localhost's
port 12345
(computer with
the graphical display) such that the user on localhost
can access
machine.remote's
port 8384
as if it was on port 12345
. The -N
flag
prevents the SSH
command from executing on the remote so that it is forced to
run as a foreground process at the command line.