Installing FreeNX 0.7.1 on Ubuntu

Introduction

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

Download nxclient, nxnode and nxserver from NoMachine as .tar.gz files. The files can be found in the NoMachine downloads or can be downloaded directly from this site, if you trust me:

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 /usr/NX.

# 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

Compiling nxcomp

Download the source code for nxcomp from NoMachine’s source code or here from
nxcomp-3.0.0-48.tar.gz.

The ./configure is not very robust and doesn’t check for missing dependencies. This are the packages that are needed to compile nxcomp:

# 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

Compiling nxcompext

Download the source code for nxcompext and nx-X11 from NoMachine’s source code or here from
nxcompext-3.0.0-18.tar.gz and nx-X11-3.0.0-37.tar.gz, and extract them:

# tar -xzf nxcompext-3.0.0-18.tar.gz
# tar -xzf nx-X11-3.0.0-37.tar.gz

Before compiling 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 /usr/NX/etc/node.conf:

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

Compiling nxcompshad

Download the source code for nxcompshad from NoMachine’s source code or here from
nxcompshad-3.0.0-19.tar.gz.

# tar -xzf nxcompshad-3.0.0-19.tar.gz
# cd nxcompshad
# ./configure --prefix=/usr/NX
# make
# cp -P libXcompshad.so* /usr/NX/lib

Compiling nxesd

Download the source code for nxesd from NoMachine’s source code or here from
nxesd-3.0.0-4.tar.gz.

# tar -xzf nxesd-3.0.0-4.tar.gz
# cd nxesd
# ./configure --prefix=/usr/NX
# make
# make install

Installing FreeNX

Download FreeNX from FreeNX downloads, or from this Web site at freenx-0.7.1.tar.gz and extract them and apply the gentoo-machine.diff patch:

# tar -xzf freenx-X.Y.Z.tar.gz
# cd freenx-X.Y.Z
# patch -p0 < gentoo-nomachine.diff

The 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 nxnode. Basically, nxserver-helper runs a command that has both /dev/fd/3 and /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 smbmount and smbumount:

$ 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 nxclient completely.

    Most of my network components are Kerberized and having to keep supplying my password to nxclient seems 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.

14 thoughts on “Installing FreeNX 0.7.1 on Ubuntu

  1. Good tutorial but you forgot to compile nx-x11 and install nxagent, nxproxy, etc, no?
    Thanks.

  2. The reason why I didn’t compile nxagent, nxproxy and company is because I’m using the binaries from the official NoMachine packages, as described in section “Installing the base NoMachine’s NX binary components” 🙂

  3. Hello,
    Thank you for your guide, I’ve followed it step by step in Kubuntu-kde4 v8.04.
    I would like to report:
    – a typo “path -p0…” -> “patch -p0…”
    – “cd ..” is missing between “make” and “cp -f nxserver-helper /usr/NX/bin/”

  4. Hello,
    In my case (kubuntu-kde4 8.04) It doesn’t work.
    Connecting from nomachine windows client this is the details log:

    NX> 203 NXSSH running with pid: 3352
    NX> 285 Enabling check on switch command
    NX> 285 Enabling skip of SSH config files
    NX> 285 Setting the preferred NX options
    NX> 200 Connected to address: 192.168.0.81 on port: 22
    NX> 202 Authenticating user: nx
    NX> 208 Using auth method: publickey
    HELLO NXSERVER – Version 2.1.0-71 OS (GPL)
    NX> 105 hello NXCLIENT – Version 2.1.0
    NX> 134 Accepted protocol: 2.1.0
    NX> 105 SET SHELL_MODE SHELL
    NX> 105 SET AUTH_MODE PASSWORD
    NX> 105 login
    NX> 101 User: josefco
    NX> 102 Password:
    NX> 103 Welcome to: kubuntukde4 user: josefco
    NX> 105 listsession –user=”josefco” –status=”suspended,running” –geometry=”1280x800x32+render” –type=”unix-kde”
    NX> 127 Sessions list of user ‘josefco’ for reconnect:
    Display Type Session ID Options Depth Screen Status Session Name
    ——- —————- ——————————– ——– —– ————– ———– ——————————
    0 vnc-local 0AD8EDF9FB3BBDC82E59E35F49BB5A0E ——– 1280×800 Running X0 (Local)
    NX> 148 Server capacity: not reached for user: josefco
    NX> 105 listsession –user=”josefco” –status=”suspended,running” –geometry=”1280x800x32+render” –type=”unix-kde”
    NX> 127 Sessions list of user ‘josefco’ for reconnect:
    Display Type Session ID Options Depth Screen Status Session Name
    ——- —————- ——————————– ——– —– ————– ———– ——————————
    0 vnc-local 8A74572A682140ECF959B97F411BAD43 ——– 1280×800 Running X0 (Local)
    NX> 148 Server capacity: not reached for user: josefco
    NX> 105 startsession –link=”lan” –backingstore=”1″ –encryption=”1″ –cache=”16M” –images=”64M” –shmem=”1″ –shpix=”1″ –strict=”0″ –composite=”1″ –media=”0″ –session=”kubuntu-kde4″ –type=”unix-kde” –geometry=”1280×800″ –client=”winnt” –keyboard=”pc102/es” –screeninfo=”1280x800x32+render”
    NX> 1000 NXNODE – Version 2.1.0-71 OS (GPL)
    NX> 700 Session id: kubuntukde4-1000-DD855FC99BF3858B808CA6EBE991D351
    NX> 705 Session display: 1000
    NX> 703 Session type: unix-kde
    NX> 701 Proxy cookie: 7090b052eecb647bb3cada9f149b3ead
    NX> 702 Proxy IP: 127.0.0.1
    NX> 706 Agent cookie: 7090b052eecb647bb3cada9f149b3ead
    NX> 704 Session cache: unix-kde
    NX> 707 SSL tunneling: 1
    /usr/NX/bin/nxserver: line 1283: 24716 Terminated sleep $AGENT_STARTUP_TIMEOUT
    NX> 105 NX> 596 Session startup failed.
    NX> 1004 Error: NX Agent exited with exit status 1. To troubleshoot set SESSION_LOG_CLEAN=0 in node.conf and investigate “/home/josefco/.nx/F-C-kubuntukde4-1000-DD855FC99BF3858B808CA6EBE991D351/session”. You might also want to try: ssh -X myserver; /usr/NX/bin/nxnode –agent to test the basic functionality. Session log follows:
    Can’t open /usr/NX/var/db/running/sessionId{DD855FC99BF3858B808CA6EBE991D351}: No such file or directory.
    mv: cannot stat `/usr/NX/var/db/running/sessionId{DD855FC99BF3858B808CA6EBE991D351}’: No such file or directory
    NX> 1006 Session status: closed
    NX> 280 Exiting on signal: 15

    I will appreciate any help.
    Thank you.

  5. I haven’t tried to install on Hardy, but I guess that it should work with no modifications at all. If you try to install FreeNX in Hardy, could you also post your comments and experiences here?

  6. fermispam,

    With respect the error messages “No such file or directory”, can you please check that /usr/NX/var/db exists and has the correct permissions? Also, you can trying enabling full logging in /usr/NX/etc/node.cfg and see if it casts additional information.

  7. Hello Felipe, thank you for your reply.
    I’ve checked that /usr/NX/var/db exists and has the correct permissions. I didn’t tried to enable full logging because I gave up this method.

    Now I’ve got it working on Hardy (Ubuntu 8.04 fresh install) following just this three steps:

    1.- Add to /etc/apt/sources.list:
    deb http://ppa.launchpad.net/marceloshima/ubuntu hardy main
    deb-src http://ppa.launchpad.net/marceloshima/ubuntu hardy main

    2.- sudo apt-get update

    3.- sudo aptitude install freenx

    Is there any difference with your method?

  8. Just to note, Marcel’s repository has a full dependency on the ubuntu-desktop package and thus requires a LOT of gnome-centric packages. DaFlame’s post contains a repository without these dependencies for folks who wish to keep their installs clear of all those unnecessary packages.

    *** INSTALL KEY FOR NEW REPOSITORY ***
    wget http://www.datakeylive.com/ubuntu/dists/gutsy/wjeremy.key -O – | sudo apt-key add –

    *** ADD BELOW TO /etc/apt/sources.list ***
    deb http://www.datakeylive.com/ubuntu hardy main
    deb-src http://www.datakeylive.com/ubuntu hardy main

    *** UPDATE ***
    sudo apt-get update

    Cheers

  9. Wow, I learned so much from this episode! I’ve always wanted to build Lamar’s tiny solar homestead house, but there were a few things about his design that I’d want to tweak to make it more sturdy and long lasting…Take-aways that I loved from this video:
    Sub floor spray foam
    recycled tire roofing shingles
    steel pin foundation
    Thanks again for sharing, I will hold on to this link for quite a while till I’m ready to build!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s