How to Setup freeNX on Centos 5

Scenario / Question:

How do I setup freeNX on a remote server system and connect to it.

Solution / Answer:

Installing the freeNX server software on the remote server machine and using the NoMachine freenx client to connect to it from you local machine.

Installing freeNX Server:

On the server you want to control with freeNX
Install freenx using yum:
# yum install nx freenx
Copy minimal configuration file:
# cp /etc/nxserver/node.conf.sample /etc/nxserver/node.conf
Enable PASSDB for NX Database User Authentication pass-through:
Uncomment and change the following line in /etc/nxserver/node.conf
ENABLE_PASSDB_AUTHENTICATION="1"
Add a user account to the nxserver database ( the user account must already exist on the system as a standard linux user account):
# nxserver --adduser <username>
Give the user a password:
# nxserver --passwd <username>

Installing freeNX NoMachine Client:

The NoMachine client needs to be downloaded from their site. Download the client that matches the operating system on your local machine.
http://www.nomachine.com/download.php
After installing the NoMachine client open the NX Connection Wizard.
Enter a Session Name, Hostname or IP of the remote server system, SSH Port number of the remote server system (usually 22), and select your connection type. Click Next
nx-connection-wizard
nx-connection-wizard
Select the connection type, desktop system and the size of the desktop. Click Next
nx-connection-wizard-1
nx-connection-wizard-1
Click Finish
nx-connection-wizard-2
nx-connection-wizard-2

freeNX SSH Keys configuration:

In order for freeNX to function securely we need to copy the ssh key from the remote server system to the local machines NoMachine client software.
On the remote server system copy the client.id_dsa.key contents (including the —BEGIN— and —- END— lines):
# cat /var/lib/nxserver/home/.ssh/client.id_dsa.key
On the local client system open the NX client software and click on “Configure”:
nx
nx
Under the General tab, click “Key”
nx-test1
nx-test1
Delete the contents and paste in the contents from the remote server system /var/lib/nxserver/home/.ssh/client.id_dsa.key
general-key-management
general-key-management
Now connect using the username and password you created when you configured freeNX on the remote server system.

Common Errors:

The nx service is not available or the nx access was disabled
The issue with the above error is that you copied the wrong ssh key and most likely followed the process from an old tutorial that told you to copy the key from /etc/nxserver or told you to create your own key. The key you should copy is found at /var/lib/nxserver/home/.ssh/client.id_dsa.key
Keyboard Layout Error
When connecting to FreeNX server your keyboard layout is giving errors. Typically the up arrow key is causing the print screen dialog to show. To correct problem you need to adjust Xorg on the client system.
Fedora:
Create xorg.conf:
# Xorg -configure :1
# cp /root/xorg.conf.new /etc/X11/xorg.conf
Add the following to xorg.conf:
Section "ServerFlags"
        Option          "AllowEmptyInput" "off"
        Option          "AutoAddDevices" "false"
        Option          "DontZap" "false"
EndSection
Restart Xorg:
ctrl-alt-backspace