FreeNX is a lifesaver. It allows you to run a remote X session on your machine at work while you are elsewhere (e.g., using your laptop). It uses a server/client architecture. Your work machine runs the nxserver program, and your laptop or remote machine runs the nxclient that connects to the server.
This document describes how to install the FreeNX server on a Gentoo linux machine, and how to install nxclient on a Mac laptop, because that is the hardware I own. This may still be useful as a rough guide for other setups as well.
The original nxserver program is a commercial product by NoMachine. They were good enough to publish the server API, so now there is a Free Software variant called FreeNX. If you wish to purchase a license from NoMachine to use their nxserver, see their homepage. This document describes the installation of the open-source FreeNX nxserver program.
First, install the necessary packages. On Gentoo, do the following as root:
emerge -v nxserver-freenx nx-x11Note: If you use the amd64 architecture, prefix the above command with
ACCEPT_KEYWORDS="~amd64". Additionally, you will need to replace nx-x11 with nx-x11-bin, because for some reason nxserver isn't configured to look for the 64-bit x11 libraries, even when compiled as amd64 (nx-x11-bin installs the 32-bit version as a precompiled binary).
Next, set it up. As root, execute the command:
nxsetup --install --setup-nomachine-key
WARNING: I had to do some seriously hackish things at this point, to get it working. The whole reason for me writing this guide is to document the following flaming hoops that I had to jump through to get this working. It's pretty lame that we need to go through all this, but trust me, the magic that is NX is totally worth it in the end. There are three errors I had to fix or workaround:
Error 1: when running the above setup command, I got the following error message:
/usr/NX/bin/nxloadconfig: line 499: [: missing `]'The "
]" isn't actually missing, but you do have to insert a space before the "]" on line 499 of /usr/NX/bin/nxloadconfig. Hopefully, the Gentoo guys will have fixed this by the time you are reading this, but if you get that error message you now know what to do.
Error 2: After fixing that problem, I got a different error message when trying to install:
Error: Invalid value "PROXY_TCP_NODELAY="I was not able to find a solution for this issue, but I do have a workaround: simply comment out these two lines in
/usr/NX/bin/nxloadconfig by adding a "#" to the front of each line:
[ -z $(echo "$PROXY_TCP_NODELAY" | egrep "^[0|1]$") ] && \
ERROR="yes" && echo "Error: Invalid value \"PROXY_TCP_NODELAY=$PROXY_TCP_NODELAY\""
Error 3: Finally, there's an obscure incompatibility issue that crops up if you are using a version 2.0 nxclient to connect to a FreeNX-0.4 or FreeNX-0.5 server. If you are following these instructions, this is almost certainly the case. The symptom for this problem is that when you attempt to connect to the server with the remote client, the connection authenticates successfully, but then you get a generic "Connection error". If you click on the Details button, you'll see a bunch of diagnostic text including a line like "NX> 596 Session startup failed.".
The fix for this error was really hard to track down; I eventually found it in the discussion attached to a Gentoo wiki page on setting up FreeNX on Gentoo. The fix is to open up the file /usr/NX/bin/nxnode in a text editor (as root), find the line:
[ -n "$backingstore" ] && B="-bs $backingstore"and immediately after this line, add:
# backingstore = { "when_requested", "always", ... }
[ -n "$backingstore" -a "$ENABLE_2_0_0_BACKEND" != "1" -a "$backingstore" != "1" ] && B="-bs $backingstore"
# backingstore = 1 (new nxclient 2.0.0 doesn't send any strings in the option-string for backingstore anymore)
[ -n "$backingstore" -a "$ENABLE_2_0_0_BACKEND" != "1" -a "$backingstore" = "1" ] && B="+bs"
# backingstore = 1 and 2.0.0-Backend EXPERIMENTAL
[ -n "$backingstore" -a "$ENABLE_2_0_0_BACKEND" = "1" ] && B="-bs $backingstore"
Ok. Now that we (finally!) have the nxserver set up correctly, we can specify any users you want to be able to initiate the NX session:
nxserver --adduser <username>The <username> should be an existing user on your server machine. Set the NX password for each user with:
nxserver --passwd <username>and enter the desired password when prompted (it need not be the same as the user's normal login password).
Next, install the nxclient on the remote machine. Here, we can use the client from NoMachine, which they provide for free. There are Free Software versions available, but until they mature a bit, I'm going to recommend the NoMachine client for now.
Go to NoMachine's Downlaod page for the Mac OSX nxclient, open the pkg file that it downloads, and click through the instructions to install the client.
Finally, you need to copy over the SSH key from your server machine to your client machine, using scp. Open a Terminal on the client machine (the Mac laptop in my case) and type:
scp root@server.address.org /usr/NX/home/nx/.ssh/client.id_dsa.key ~/.
Now launch the NX Client for Mac OSX app, and follow the wizard setup to set the name of the remote machine and your username. When you are finished, you will be presented with the NX login window. (Note: the following stuff about importing the key may not be strictly necessary since we are using the default NoMachine key. If you're feeling impatient (and who can blame you?), you could just try to open a session now without doing the following stuff...)
Before you attempt to log in for the first time, you need to import the SSH key that you copied over from the server. Click on the Configure... button. Near the top of the window, you'll see a Server group box containing your server name and some other stuff. Click on the Key... button in this box. In the window that opens, Click the Import... button, and navigate the ugly gnome file dialog to the client.id_dsa.key file that you copied over. Then click Save in both the Key window and the main Configuration window.
You should now be able to log in and start a remote desktop session. Have fun!