Let's say I have a Linux workstation at work, behind a firewall. So even though I may have a remote access server set up on it (such as the most excellent NoMachine NX Server), I can't access it from home.

My home network happens to have a Linux server. Is it possible to ssh from work to the home Linux machine and set up a tunnel so that once I'm at home, I can run the NX client, point it to my home Linux box on some port like 9000, and have that forward through the tunnel to port 22 on my work Linux box? How would I set this up?

  • Your company doesn't provide some kind of vpn access? – Keith Apr 22 '11 at 17:19

From the machine at work, create a tunnel to your machine running ssh at home:

randolf@workserver:~$ ssh -vvv randolf@myhomeserver -R 44455:localhost:22

This will forward the remote port 44455 from your home server to port 22 (or whichever port ssh is listening on) on your work machine.

From home, check to see if anything is listening on 44455

randolf@homeserver:~$ netstat -an | grep 44455
tcp        0      0*               LISTEN 

Next, to connect from home to your work machine, from your home server:

randolf@homeserver:~$ ssh localhost -p 44455
Password: ******

From there you should be connected to your work machine via your tunnel.

  • Perfect, exactly what I was looking for. Then I can use NX to log in remotely. – CaptSaltyJack May 27 '11 at 22:11
  • Awesome, glad to have helped! – CJ Travis May 30 '11 at 13:06

You could set some port forwarding up with your firewall, or possibly even use a tool like "bounce" to re-direct ports if there are some restrictions on what you're allowed to do with your firewall, but here's what I'd do if I were you:

Install the excellent free, open source, userland OpenVPN software. Set up the target server as an OpenVPN client (and configure infinite connection retries), and your home Linux server as the OpenVPN server. This way, the target server running the OpenVPN client will be connected to your home Linux server whenever it's operational and connected to the internet -- through this VPN connection, you can have full access to your work/target server (running the OpenVPN client).

  OpenVPN (full-featured free, open source, userland VPN solution)

  • So just to make sure I have this right: my home Linux box runs an OpenVPN server, and my Linux box at work runs an OpenVPN client that stays connected to my Linux home VPN? And that will allow me (at home) to remote into my work Linux box? – CaptSaltyJack Apr 22 '11 at 17:13
  • @CaptSaltyJack: Yes. The purpose of an VPN is to extend the network to another computer or another network of more computers, and communications can go both ways. You can set either one up as the VPN server (and it probably would be more useful to set your work one up as the server, but the way you asked your question prompted me to suggest otherwise -- it really doesn't matter which way you do it though). The OpenVPN server's private IP will be (default), and the first OpenVPN client will be (default) -- they'll be able to ping/connect-to each other. – Randolf Richardson Apr 22 '11 at 17:16
  • @CaptSaltyJack: The server that has a static IP address should really also be the OpenVPN server though (unless it has a hostname that changes automatically with the IP). – Randolf Richardson Apr 22 '11 at 17:17
  • Well, at work, the network is set up in a way that all the computers are firewalled and to the external world they have one IP. So I don't think I could run a VPN server on my work machine and connect to it. I'd probably have to have it connect to my home machine. – CaptSaltyJack Apr 22 '11 at 17:40
  • @CaptSaltyJack: Just as I suspected. Either way you set it up (whichever side is the OpenVPN server), your applications (including ssh) won't know the difference. – Randolf Richardson Apr 22 '11 at 18:06

How to connect to a Linux box on port 3389 (RHEL5)

Unfortunately, port 22 is blocked by many firewalls and tunnels may open security holes so the best approach is to set ssh and NX to listen on port 3389 instead of the standard 22 which may confuse the majority of hackers

Configure OpenBSD to listen to port 3389

vim /etc/ssh/sshd_config

Port 3389

service sshd restart

Download NX Client for Windows to the RHEL ftp site


Download NX Free Edition for Linux


As root - Install NX in this order

rpm –ivh nxclient-3.5.0-7.i386.rpm
rpm –ivh nxnode-3.5.0-9.i386.rpm
rpm –ivh nxserver-3.5.0-11.i386.rpm

Configure NX for port 3389

vim /usr/NX/etc /node.cfg
# Specify the TCP port where the NX node SSHD daemon is running.
SSHDPort = "3389"

vim /usr/NX/etc /server.cfg
# Specify the TCP port where the NX server SSHD daemon is running.
SSHDPort = "3389"

service nxsensor restart
nxserver --daemon restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.