DISCLAIMER: The contents of this post are mostly based on Manual Installation How-To. Thanks to Brent Davidson and Fabian Franz for writing such a nice HowTo and the beautiful open and free implementation of FreeNX, respectively.
I decided to use FreeNX instead of NoMachine’s own implementation due to the instability of the latter. Most of the times, I could not reconnect to my running sessions, or else NX decided to kill my running session and start a new one. FreeNX is a collection of shell scripts, which makes it easier to debug and troubleshoot problems.
The process described in this post starts with the NoMachine’s binary components, downloadable from the Web, and then overwrites or replaces key components that are binary-only and closed with FreeNX’s open and free shell scripts, which provides much more flexibility. In my own experience, FreeNX is more robust, stable, predictable, easier to customize and to debug than NoMachine’s closed binary components.
Installing the base NoMachine’s NX binary components
For IA-32 systems:
For x86_64 systems:
Extract the files to
/usr. Since the
.tar.gz packages always contain relative pathnames that start with
./NX, this will create a whole directory tree under
# tar -C /usr –xzf nxserver-3.0.0-79.i386.tar.gz # tar -C /usr –xzf nxclient-3.0.0-84.i386.tar.gz # tar -C /usr –xzf nxnode-3.0.0-93.i386.tar.gz
Compiling the NX compression libraries
./configure is not very robust and doesn’t check for missing dependencies. This are the packages that are needed to compile
# apt-get install zlib1g-dev libX11-dev libjpeg-dev libpng12-dev x11proto-xext-dev libxdamage-dev libxrandr-dev libxtst-dev libaudiofile-dev
Configuring, building the library and copying it to its final location is just as easy as running:
# tar -xzf nxcomp-3.0.0-48.tar.gz # cd nxcomp # ./configure --prefix=/usr/NX # make # cp -P libXcomp.so* /usr/NX/lib
# tar -xzf nxcompext-3.0.0-18.tar.gz # tar -xzf nx-X11-3.0.0-37.tar.gz
nxcompext, apply the NXlib-xgetioerror.patch.
# cd nxcompext # patch -p0 < NXlib-xgetioerror.patch
This is required or else the resulting
libXcomp.so shared library will complain about
_XGetIOError symbol being undefined. In order to troubleshoot this, I had to enable logging in
NX_LOG_LEVEL=7 SESSION_LOG_CLEAN=0 NX_LOG_SECURE=0
Then, looking at
/var/log/nxserver.log I found the following error message:
Info: Established X client connection. Info: Using shared memory parameters 1/1/1/4096K. Info: Using alpha channel in render extension. Info: Not using local device configuration changes. /usr/NX/bin/nxagent: symbol lookup error: /usr/NX/lib/libXcompext.so.3: undefined symbol: _XGetIOError NX> 1006 Session status: closed
Applying the patch solves the problem:
# ./configure --x-includes="/usr/include/xorg -I/usr/include/X11" --prefix=/usr/NX # make # cp -P libXcompext.so* /usr/NX/lib
# tar -xzf nxcompshad-3.0.0-19.tar.gz # cd nxcompshad # ./configure --prefix=/usr/NX # make # cp -P libXcompshad.so* /usr/NX/lib
# tar -xzf nxesd-3.0.0-4.tar.gz # cd nxesd # ./configure --prefix=/usr/NX # make # make install
# tar -xzf freenx-X.Y.Z.tar.gz # cd freenx-X.Y.Z # patch -p0 < gentoo-nomachine.diff
gentoo-machine.diff patch must be applied if you are using the
/usr/NX directory structure that the NoMachine libraries use.
Next, we replace the original NoMachine key binaries (in fact, they are compiled Perl scripts) with the FreeNX shell scripts:
# cp -f nxkeygen /usr/NX/bin/ # cp -f nxloadconfig /usr/NX/bin/ # cp -f nxnode /usr/NX/bin/ # cp -f nxnode-login /usr/NX/bin/ # cp -f nxserver /usr/NX/bin/ # cp -f nxsetup /usr/NX/bin/ # cp -f nxcups-gethost /usr/NX/bin/
Next, we need to compile the
nxserver-helper binary, which is used by the slave mode of
nxserver-helper runs a command that has both
/dev/fd/4 mapped into both ends of a UNIX SOCKET.
# cd nxserver-helper # make # cp -f nxserver-helper /usr/NX/bin/
Before being able to set up the FreeNX, install
expect, the OpenSSH server and
$ sudo apt-get install expect smbfs openssh-server
The next step creates symbolic links in
/usr/bin to all FreeNX scripts that live in
/usr/NX/bin and additional symbolic links for NX compatibility:
# ln -s /usr/NX/bin/nxserver /usr/bin/nxserver # ln -s /usr/NX/bin/nxsetup /usr/sbin/nxsetup # ln -s /usr/NX/bin/nxloadconfig /usr/sbin/nxloadconfig # ln -s /usr/NX/lib/libXrender.so.1.2.2 /usr/NX/lib/libXrender.so.1.2 # ln -s /usr/NX/bin/nxagent /usr/NX/bin/nxdesktop # ln -s /usr/NX/bin/nxagent /usr/NX/bin/nxviewer # ln -s /usr/bin/foomatic-ppdfile /usr/lib/cups/driver/foomatic-ppdfile # ln -s /etc/X11/xinit /etc/X11/xdm # ln -s /sbin/mount.cifs /sbin/smbmount # ln -s /sbin/umount.cifs /sbin/smbumount
The final step consists is running the installation stage of FreeNX:
# nxsetup --install
This will create
/usr/NX/var directory tree, create the
nx user, install the appropiate SSH keys (either the NoMachine’s keys or custom keys).
Before being able to use FreeNX, create the
node.conf configuration file that allow changing the behavior of FreeNX, like logging, path names to several scripts used to start GNOME or KDE, and so on:
# cd freenx-X.Y.Z # cp node.conf.sample /usr/NX/etc/node.conf
Future development and ideas
- Not having to depend on any single binary file from NoMachine.
The idea is compiling all the components from source code, instead of starting with a binary distribution and replacing key components with their open and free counterparts.
- Customizing FreeNX so that I can bypass NoMachine’s
Most of my network components are Kerberized and having to keep supplying my password to
nxclientseems like a thing of the past to me. The idea is customizing FreeNX in such a way that I can leverage Kerberos authentication and drop password-based authentication completely.