Running NoMachine NX in parallel with FreeNX.

Prerequisite

This howto assumes that you have FreeNX already installed and properly configured. If it’s not the case, you can install it from my repo with the following command:


su -l
zypper ar http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.1/  PTA
zypper refresh -r PTA
zypper in FreeNX

and set it up with default keys with:

nxsetup --install --setup-nomachine-key
  • Obviously you have to perform the tasks described below in a root terminal (except downloading the rpms from NoMachine and surfing the web for addtional info).

Open 2 additional SSH ports

To run FreeNX and NoMachine NX together, they have to listen on different ssh ports. In this example I will run FreeNX on port 9122 and NoMachine NX on port 9123. You should add them in /etc/ssh/sshd_config (below Port 22).


.../...
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.

Port 22
Port 9122
Port 9123
.../...

After modifying /etc/ssh/sshd_config, you should restart the ssh daemon.

  • In system V:
system sshd restart
  • In systemd:
systemctl restart sshd.service

although the service command works too.

Notice that you don’t need to run FreeNX on another port than port 22 (the default). So adding only one extra port would have been suficient. In this example (as well as in real life), I just run FreeNX on a port different from standard ssh.

Modify FreeNX /etc/nxserver/nodeconf

Apply the following changes to** /etc/nxserver/nodeconf**:

#  diff node.conf.orig node.conf
51c51
< #SSHD_PORT=22
---
> SSHD_PORT=**9122**
328,329c328,329
< #ENABLE_NOMACHINE_FORWARD_PORT="0"
< #NOMACHINE_FORWARD_PORT="22"
---
> ENABLE_NOMACHINE_FORWARD_PORT="1"
> NOMACHINE_FORWARD_PORT="**9123**"
331,332c331,332
< #NOMACHINE_SERVER="/usr/NX/bin/nxserver"
< #NOMACHINE_NX_HOME_DIR="/usr/NX/home/nx"
---
> NOMACHINE_SERVER="/usr/NX/bin/nxserver"
> NOMACHINE_NX_HOME_DIR="/usr/NX/home/nx"

Dowmload NoMachine NX 3.5.0 Free Edition rpm packages

I never used NX 4 - I doubt it will work with FreeNX, but you’re welcome to try and report.

You need to download nxnode, nxserver and - if you don’t have it already -* nxclient* for your architecture.

Let us put then in /tmp (although you might want to save then somewhere else).

cd /tmp

  • 64bit:
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/nxnode-3.5.0-7.x86_64.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/nxnode-3.5.0-7.x86_64.rpm)
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/FE/nxserver-3.5.0-9.x86_64.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/FE/nxserver-3.5.0-9.x86_64.rpm)
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/nxclient-3.5.0-7.x86_64.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/nxclient-3.5.0-7.x86_64.rpm)

  • 32bit:
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/nxnode-3.5.0-7.i386.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/nxnode-3.5.0-7.i386.rpm)
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/FE/nxserver-3.5.0-9.i386.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/FE/nxserver-3.5.0-9.i386.rpm)
wget [noparse] http://64.34.161.181/download/3.5.0/Linux/nxclient-3.5.0-7.i386.rpm[/noparse]](http://64.34.161.181/download/3.5.0/Linux/nxclient-3.5.0-7.i386.rpm)

Should these files not be available anymore, check on the NoMachine download page.

Delete the nx user

The installation of nxserver will fail if the nx user already exists. You have to delete it but first you have to remember its current UID and GID, as NoMachine postinstall script will probably give it another one.

On my systems, it is always 126:126 (I chose it):

# id nx  
uid=126(nx) gid=126(nx) groups=126(nx),22(utmp)

It will help to take a look at the nx entry in /etc/passwd and copy/paste it somewhere:

# grep nx /etc/passwd
nx:x:126:126:FreeNX Server,,,:/var/lib/nxserver/home:/usr/bin/nxserver

Now that you remember this information, you can delete the nx user:

# userdel nx

install nxserver and nxnode

Go to the directory where you stored the rpms and install the packages:

# cd /tmp
# zypper in nxclient-3.5.0-7.x86_64.rpm
# zypper in nxnode-3.5.0-7.x86_64.rpm
# zypper in nxserver-3.5.0-9.x86_64.rpm

You might already have the nxclient or use another one.

Modify nx user and NoMachine NX file ownership

Now comes the tricky part. The new nx user created by NoMachine has a different user and group id.
Except for the name, you will notice that every single field is different from the previous one:


# grep nx /etc/passwd
nx:x:144:1001::/usr/NX/home/nx:/usr/NX/bin/nxserver

You need to remember the UID and GID provided by NoMachine. In the example above, 144 and 1001.
Now, modify the nx user, so that it matches the one originally created by FreeNX


usermod -u 126 -g 126 -c "FreeNX Server,,," -d /var/lib/nxserver/home -s /usr/bin/nxserver nx

Keep in mind that yours won’t have 126 as UID/GID.

Change the ownership of the NX files:

find /usr/NX -uid 144 -exec chown nx "{}" ";"

Modify NoMachine NX configuration

Change the default SSH port in /usr/NX/etc/server.cfg and /usr/NX/etc/node.cfg. I also enable DirectXdmQuery (Don’t know if you need it).

# diff server.cfg.orig server.cfg
36c36
< #SSHDPort = "22"
---
> SSHDPort = "**9123**"
318c318
< #EnableDirectXdmQuery = "0"
---
> EnableDirectXdmQuery = "1"
350c350
< #SSHDCheckIP = "0"
---
> SSHDCheckIP = "1"

# diff node.cfg.orig node.cfg
349c349
< #SSHDPort = "22"
---
> SSHDPort = "**9123**"
511d510

Restart freenx and nx daemons

**# service freenx-server restart**
No processes found.
NX> 100 NXSERVER - Version 3.2.0-73 OS (GPL, using backend: 3.4.0)
NX> 123 Service stopped
NX> 122 Service started
NX> 999 Bye

**# service nxserver restart**
Trying to restart NX server:
NX> 123 Service stopped.
NX> 153 Stopping NX server monitor.
NX> 153 NX server monitor already stopped.
NX> 122 Service started.
NX> 999 Bye.
Trying to restart NX statistics:
NX> 723 Cannot start NX statistics:
NX> 709 NX statistics are disabled for this server.
NX> 999 Bye.


Connecting to freenx or nx

Every request on port 9123 will first reach FreeNX, then get forwarded to NoMachine NX.
Set the port in the client to 9122 to open a FreeNX session and 9123 for a NoMachine session.

NoMachine Free Edition Nx sessions are limited to one per client.

FreeNX and NoMachine servers don’t behave exactly the same way. With FreeNX, Unix XDM sessions directly start the default WINDOW_MANAGER, while NoMachine’s display the xdm/gdm or kdm login screen - where you can select the window manager to start.

I have to make a correction. /etc/init.d/freenx-server is not in my package or in other freenx packages for openSUSE - as far as I know. I happen to have this script on my system because I might have copied it one day from another distro, but it’s actually neither required nor useful. Please disregard this command.