Freenx
From Mandriva Community Wiki
Contents |
Introduction
While it is possible to open up a graphical application over an ssh session the X protocol is far too bandwidth intensive and intolerant of latency to be usable over wide area networks with restricted bandwidth and high latency. Traditionally the solution to the need for accessing a remote desktop would be to use vnc to compress the X protocol traffic. Vnc is certainly an improvement, but it is still not adequate for slower connections.
To solve this problem NoMachine have developed the NX protocol which operates by creating an X session over ssh between a special user on the server and the server itself. The NX protocol then passes a differential of the screen contents of this session to the remote client over a second ssh session. The result is a remote desktop that is perfectly usable even for low bandwidth high latency connections.
Like all good things there is a price to pay, and with NX protocol the price is complexity in setting up the session. This guide is going to show how to configure a server running Mandriva 2009.1 to run freenx, the open source implementation of the NX protocol, and a remote client running the 'free as in beer' NX client from NoMachine. There is actually an open source client called qtnx, but because it is not packaged for Mandriva we shall be focusing on the NoMachine client.
Server Configuration
Install the freenx server
# urpmi freenx
To satisfy dependencies, the following packages are going to be installed:
Package Version Release Arch
(medium "contrib")
freenx 0.7.3 2mdv2009.1 i586
nxagent 3.3.0 2mdv2009.1 i586
4.5MB of additional disk space will be used.
1.3MB of packages will be retrieved.
Proceed with the installation of the 2 packages? (Y/n) y
http://www.mirrorservice.org/sites/carroll.cac.psu.edu/MandrivaLinux/official/2009.1/i586/media/contrib/release/nxagent-3.3.0-2mdv2009.1.i586.rpm
http://www.mirrorservice.org/sites/carroll.cac.psu.edu/MandrivaLinux/official/2009.1/i586/media/contrib/release/freenx-0.7.3-2mdv2009.1.i586.rpm
installing nxagent-3.3.0-2mdv2009.1.i586.rpm freenx-0.7.3-2mdv2009.1.i586.rpm from /var/cache/urpmi/rpms
Preparing... ##########################################################################################################################################
1/2: nxagent ##########################################################################################################################################
2/2: freenx ##########################################################################################################################################
----------------------------------------------------------------------
More information on package freenx-0.7.3-2mdv2009.1.i586
After installing this package, an nx user is created (this is a
system user, do not try to log in as him), with a home located
at /var/lib/nxserver/nxhome. His password is a random
32-character password.
Your user must install the key located at:
/var/lib/nxserver/nxhome/.ssh/client.id_dsa.key
to log in.
For knx, put it in: /usr/share/knx/ with world-readable right.
For nomachine.com Nx client for windows put it in : C:\Program
Files\NX Client for Windows\share
You user will now be able to log in using their username
and password provided you have ssh logins enabled for them
----------------------------------------------------------------------
Ignore the text displayed above for the moment. We will deal with the ssh key later.
Next we must edit the file /etc/rc.local to ensure the directory /tmp/.X11-unix is created with write permission each time the server is booted. This is necessary because Mandriva 2009.1 will clean out /tmp on each boot.
Using your favourite editor as root user edit /etc/rc.local to add these lines to the end
if [ ! -d /tmp/.X11-unix ] ; then
mkdir /tmp/.X11-unix
chmod 1777 /tmp/.X11-unix
fi
Then reboot and check the directory /tmp/.X11-unix has been created. If this directory is not present the nx client will not be able to complete the connection to the server.
Now edit the file /etc/nxserver/node.conf to set these parameters
ENABLE_SSH_AUTHENTICATION="1" ENABLE_SLAVE_MODE="1" ENABLE_1_5_0_BACKEND="0"
Leave all other parameters as default. Pay care, the parameter ENABLE_1_5_0_BACKENDappears twice.
The parameter 'ENABLE_SSH_AUTHENTICATION="1"' will allow any user able to open an ssh session to open an nx session.
If you cannot ssh to the server using a username and password combination then Freenx will not work. So in the ssh server configuration file /etc/ssh/sshd_config you must have the settingPasswordAuthentication yes
If you want to be more restrictive to allow only specific users to open nx sessions then set the parameters.
ENABLE_PASSDB_AUTHENTICATION="1" ENABLE_SSH_AUTHENTICATION="0"
And give the commands
nxserver --adduser username nxserver --passwd username
The server is now ready to use. The server does not need to be restarted on each boot of the computer, but if you did want to start and stop it manually the commands to do so are
nxserver --start nxserver --stop
Note. It is not necessary to set up the special nx user or mess about with ssh keys like some early guides to freenx will tell you. The Mandriva rpm install script has done it all for you.
Client Configuration
Install the nxclient rpm package from the NoMachine download page .
There is a client for Windows too for those who still use it.
# wget http://64.34.161.181/download/3.3.0/Linux/nxclient-3.3.0-6.i386.rpm --2009-05-26 13:00:45-- http://64.34.161.181/download/3.3.0/Linux/nxclient-3.3.0-6.i386.rpm Connecting to 64.34.161.181:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4484844 (4.3M) [application/x-rpm] Saving to: `nxclient-3.3.0-6.i386.rpm' 100%[===================================================================================================================================>] 4,484,844 542K/s in 9.1s 2009-05-26 13:00:54 (483 KB/s) - `nxclient-3.3.0-6.i386.rpm' saved [4484844/4484844] [root@Derek SPECS]# urpmi nxclient-3.3.0-6.i386.rpm
From your menu open up the NXclient Wizard Menu>Internet>NXClientforLinux>NXConnectionWizard
When the wizard opens choose a name for the session, the server host name, and the connection speed.
Next select the session type and the size of the window.
When the wizard exits the nxclient window will appear. Click on 'Configure', then 'key' In the box that appears delete the text and replace it with the contents of the file /var/lib/nxserver/nxhome/.ssh/client.id_dsa.key from the server. This is the ssh key.
Testing freenx
In the client enter your user name and password and select 'Connect' If all goes well you will see your chosen desktop appear.
To close a session use Ctl+Alt+T If you close the desktop by logging out it will not actually close the nx session. It will remain using up memory and resources until you log on again.
The command nxserver --list will list running sessions, and nxserver --cleanup will terminate running sessions.
Debugging
If it does not work the failure is likely to be in one of two areas.
1/ Authentication - If ssh does not work nor will freenx. The client dialogue will tell you if it has passed the authentication stage. So for example if the server key has not been entered into the client, authentication will fail.
2/ Establishing X session. This will go wrong if for example /tmp/.X11-unix is not globally writable, or the desktop you are trying to start does not exist on the server.
If it does not work go through this checklist
Can you ssh to the server with a normal ssh session using that user name and password?
In /etc/nxserver/node.conf enable debugging with
NX_LOG_LEVEL=5 NX_LOGFILE=/var/log/nxserver.log SESSION_LOG_CLEAN=0
Follow the advice at the Freenx wiki

