Install FreeNX server on Ubuntu 11.10 oneiric and 12.04 LTS precise








  • The following script compile and install freenx server on Ubuntu 11.10 oneiric and Ubuntu 12.04 LTS precise:
    #!/bin/bash
    
    ARC=`uname -m`
    if [[ `echo $ARC | egrep 'i[3456]86'` ]]; then
        ARC=i386
    else
        ARC=x86_64
    fi
    
    # NOMACHINE NX binary packages
    URL_NXCLIENT=http://64.34.161.181/download/3.5.0/Linux/nxclient-3.5.0-7.${ARC}.tar.gz
    PKG_NXCLIENT=nxclient-3.5.0-7.${ARC}.tar.gz
    
    URL_NXNODE=http://64.34.161.181/download/3.5.0/Linux/nxnode-3.5.0-7.${ARC}.tar.gz
    PKG_NXNODE=nxnode-3.5.0-7.${ARC}.tar.gz
    
    URL_NXSERVER=http://64.34.161.181/download/3.5.0/Linux/FE/nxserver-3.5.0-9.${ARC}.tar.gz
    PKG_NXSERVER=nxserver-3.5.0-9.${ARC}.tar.gz
    
    # FREENX-SERVER source package
    URL_FREENX=http://aarnet.dl.sourceforge.net/project/freenx.berlios/freenx-server-0.7.3.tar.gz
    PKG_FREENX=freenx-server-0.7.3.tar.gz
    DIR_FREENX=freenx-server-0.7.3
    
    # Install required packages
    echo "Installing required packages: ssh patch expect smbfs xutils-dev..."
    sudo apt-get update
    sudo apt-get install -y ssh patch expect smbfs xutils-dev
    
    # Create a temp working directory
    CUR_DIR=`pwd`
    TMP_DIR=`mktemp -d`
    
    # Install nomachine nxclient package
    echo -n "Downloading nomachine ${URL_NXCLIENT}..."
    cd $TMP_DIR
    wget $URL_NXCLIENT || exit 1
    echo "done"
    
    echo "Extracting ${PKG_NXCLIENT} to /usr/NX..."
    cd /usr
    sudo tar -zxvf ${TMP_DIR}/${PKG_NXCLIENT}
    cd $TMP_DIR
    
    # Install nomachine nxnode package
    echo -n "Downloading nomachine ${URL_NXNODE}..."
    cd $TMP_DIR
    wget $URL_NXNODE || exit 1
    echo "done"
    
    echo "Extracting ${PKG_NXNODE} to /usr/NX..."
    cd /usr
    sudo tar -zxvf ${TMP_DIR}/${PKG_NXNODE}
    cd $TMP_DIR
    
    # Install nomachine nxserver package
    echo -n "Downloading nomachine ${URL_NXSERVER}..."
    cd $TMP_DIR
    wget $URL_NXSERVER || exit 1
    echo "done"
    
    echo "Extracting ${PKG_NXSERVER} to /usr/NX..."
    cd /usr
    sudo tar -zxvf ${TMP_DIR}/${PKG_NXSERVER}
    cd $TMP_DIR
    
    # Install freenx-server
    echo -n "Downloading ${URL_FREENX}..."
    cd $TMP_DIR
    wget ${URL_FREENX}
    echo "done"
    
    echo "Extracting ${PKG_FREENX}..."
    cd ${TMP_DIR}
    tar zxvf ${TMP_DIR}/${PKG_FREENX}
    
    # Patch the source files: nxloadconfig Makefile node.conf.sample
    cd ${TMP_DIR}/${DIR_FREENX}
    patch -p0 < gentoo-nomachine.diff
    sed -e "s/3\.\[012\]/3\.\[012345\]/g" -i.bak nxloadconfig
    sed -e "s/foomatic-ppdfile/foomatic/g" -i.bak nxloadconfig
    sed -e "s/etc\/cups\//usr\/share\/cups\/mime/g" -i.bak nxloadconfig
    sed -e "s/PATH_BIN PATH_LIB CUPS_BACKEND NX_VERSION/& NX_ETC_DIR/g" -i.bak Makefile
    sed -e "s/sample \$(DESTDIR)\/\$\$NX_ETC_DIR\//&node.conf/g" -i.bak Makefile
    sed -e "s/#COMMAND_MD5SUM=\"openssl md5\"/COMMAND_MD5SUM=\"md5sum\"/g" -i.bak node.conf.sample
    sed -e "s/foomatic-ppdfile/foomatic/g" -i.bak node.conf.sample
    sed -e "s/etc\/cups/usr\/share\/cups\/mime/g" -i.bak node.conf.sample
    sed -e "s/#COMMAND_SMBUMOUNT=smbumount/COMMAND_SMBUMOUNT=umount/g" -i.bak node.conf.sample
    sed -e "s/#COMMAND_SMBUMOUNT_CIFS=\/sbin\/umount.cifs/COMMAND_SMBUMOUNT=\/bin\/umount/g" -i.bak node.conf.sample
    [[ -f /usr/share/xsessions/ubuntu-2d.desktop ]] && sed -e "s/#COMMAND_START_GNOME=gnome-session/COMMAND_START_GNOME=\"gnome-session --session=ubuntu-2d\"/g" -i.bak node.conf.sample
    ln -s /usr/NX/lib/libXrender.so.1.2.2 /usr/NX/lib/libXrender.so.1.2
    
    rm *.bak
    
    # Compile and install
    make
    sudo make install
    
    # Run nxsetup
    sudo /usr/NX/bin/nxsetup --install --setup-nomachine-key
    
    # Install starup script
    cd /etc/init.d
    sudo wget -O freenx http://computingplugs.com/files/nxserver
    sudo chmod +x freenx
    sudo update-rc.d freenx defaults
    
    # Clean up
    cd $CUR_DIR
    rm -fr $TMP_DIR
    
    
  • You can download the script and execute it with the following command:
    sudo chmod +x /path/to/freenx-install.sh
    sudo /path/to/freenx-install.sh
    

How to configure the NX server to make it work with Unity 2D?

If your computer comes without 3D graphics support, the ubuntu will fall into unity 2D automatically, in this case, the nx session should work fine with unity 2D
If your computer comes with 3D graphics support, by default, the ubuntu will try to use Unity (3D) as its desktop session. However, the nx server does not support Unity (3D) so far. In this case the nx session will fail to work. To solve it, you have to change the nx server configuration to use Unity 2D or Gnome classic specificly.
The following commands will configure the NX server to unity 2D(Tested on Ubuntu 12.04):
  • To configure NX server to use unity 2D:
    • Edit /usr/NX/etc/node.conf file as root, and enable the following line:
      COMMAND_START_GNOME="gnome-session --session=ubuntu-2d"
      
    • Restart freenx server:
      sudo /etc/init.d/freenx restart
      
  • To configure NX server to use gnome-shell:
    • Install gnome-shell:
      sudo apt-get install gnome-shell
      
    • Edit /usr/NX/etc/node.conf file as root, and enable the following line:
      COMMAND_START_GNOME="gnome-session --session=gnome"
      
    • Restart freenx server:
      sudo /etc/init.d/freenx restart
      
  • To configure NX server to use gnome-session-fallback:
    • Install gnome-session-fallback:
      sudo apt-get install gnome-session-fallback
      
    • Edit /usr/NX/etc/node.conf file as root, and enable the following line:
      COMMAND_START_GNOME="gnome-session --session=gnome-fallback"
      
    • Restart freenx server:
      sudo /etc/init.d/freenx restart
      

Note:

  • The scripts has been tested and works the following version of Ubuntu Linux:
    • Ubuntu Desktop 11.10 32bit
    • Ubuntu Desktop 11.10 32bit
    • Ubuntu Desktop 12.04 LTS 32bit
    • Ubuntu Desktop 12.04 LTS 64bit

Update(5 May 2012): Easy installation using the all in one binary

For convenience, I have compiled the free nx server and developed an installer script to install the compiled binaries (so that you do not have to run the script above to download and compile from source). It includes both 32 bit and 64 bit binaries.
  1. Download the freenx.bin
  2. Run the following commands to install:
    chmod +x /path/to/freenx.bin
    /path/to/freenx.bin
    
FYI: I use this method to build the self-extractable installer.

Update(15 Oct 2012): Solve the authentication failure by generating custom key pair.

For some reason, the default nomachine key pair comes with the installation no longer work. Therefore, the nx client could not login because of the key authentication failure.

The solution is: Generate and use custom pair
  1. On the nx server host, remove the old ssh key pairs for the nx user:
    sudo rm /usr/NX/home/nx/.ssh
  2. On the nx server host, generate new custom key pair:
    sudo /usr/NX/bin/nxsetup --install
    When asking:
    Do you want to use your own custom KeyPair? [y/N]
    Answer is y. It will generate files (key pair) in /usr/NX/home/nx/.ssh/. And /usr/NX/home/nx/.ssh/client.id_dsa.key is the file you need to distribute to your nx clients.
  3. In the configuration of NX client (Nomachine nx client or OpenNX client), import the newly generate key file: /usr/NX/home/nx/.ssh/client.id_dsa.key
  4. Now you should be able to login via nx client...



42 comments:

  1. Thanks a lot. Your script works like a charm.

    ReplyDelete
  2. 64 desktop
    clear system
    ----> Testing your nxserver configuration ...
    Warning: Could not find nxdesktop in /usr/NX/bin. RDP sessions won't work.
    Warning: Could not find nxviewer in /usr/NX/bin. VNC sessions won't work.
    Warning: Invalid value "APPLICATION_LIBRARY_PRELOAD=/usr/NX/lib/libX11.so.6.2:/usr/NX/lib/libXext.so.6.4:/usr/NX/lib/libXcomp.so:/usr/NX/lib/libXcompext.so:/usr/NX/lib/libXrender.so.1.2". /usr/NX/lib/libXrender.so.1.2 could not be found. Users will not be able to run a single application in non-rootless mode.
    Warning: Invalid value "DEFAULT_X_SESSION=/etc/X11/xdm/Xsession"
    Users might not be able to request a default X session.
    Warning: Invalid value "COMMAND_START_KDE=startkde"
    Users will not be able to request a KDE session.
    Warning: Invalid value "COMMAND_START_CDE=cdwm"
    Users will not be able to request a CDE session.
    Warning: Invalid cupsd version of "/usr/sbin/cupsd". Need version 1.2.
    Users will not be able to enable printing.

    Warnings occured during config check.
    To enable these features please correct the configuration file.

    <---- done

    ----> Testing your nxserver connection ...
    The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
    ECDSA key fingerprint is e0:89:dc:5f:07:eb:8c:20:f1:e7:bb:f4:8c:c6:a6:f4.
    Are you sure you want to continue connecting (yes/no)?
    Warning: Permanently added '127.0.0.1' (ECDSA) to the list of known hosts.
    Fatal error: Could not connect to NX Server.

    Please check your ssh setup:

    The following are _examples_ of what you might need to check.

    - Make sure "nx" is one of the AllowUsers in sshd_config.
    (or that the line is outcommented/not there)
    - Make sure "nx" is one of the AllowGroups in sshd_config.
    (or that the line is outcommented/not there)
    - Make sure your sshd allows public key authentication.
    - Make sure your sshd is really running on port 22.
    - Make sure your sshd_config AuthorizedKeysFile in sshd_config is set to authorized_keys2.
    (this should be a filename not a pathname+filename)
    - Make sure you allow ssh on localhost, this could come from some
    restriction of:
    -the tcp wrapper. Then add in /etc/hosts.allow: ALL:localhost
    -the iptables. add to it:
    $ iptables -A INPUT -i lo -j ACCEPT
    $ iptables -A OUTPUT -o lo -j ACCEPT
    --2012-04-29 00:11:32-- http://computingplugs.com/files/nxserver
    Resolving computingplugs.com (computingplugs.com)... 98.155.252.46
    Connecting to computingplugs.com (computingplugs.com)|98.155.252.46|:80... connected.

    ReplyDelete
    Replies
    1. 11.10 or 12.04? I can install the 64 bit vm to have a look.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. Hi Wilson,

      Thanks for the great work.
      I'm using ubuntu 12.04 64-bit with GNOME, the freenx runs well.
      But one thing need to be fixed, there is no tool bar on the screen. So I don't know how to run applications.

      Delete
    4. I have tested on Ubuntu 12.04 64 bit and 32 bit. Works fine. Make sure you downloaded the install-freenx.sh from the link and run it as sudoer or root.

      Delete
    5. Hi, Andrew,

      Which tool bar do you refer? the Left side bar?

      Maybe the desktop was not fully loaded. You can try to terminate the session and try to log in to the server.

      BTW: to open an application, try Alt+F2.

      Delete
    6. I'd like to point out that the file node.conf to modify in my original Ubuntu server 12.04 is not located in /usr/NX/etc/ but instead in /etc/nxserver

      I just needed to uncomment the #COMMAND_START_GNOME="gnome-session --session=ubuntu-2d"

      Beside that it worked like a charm ! Thanks !

      Delete
    7. To Andrew,

      I think you are puzzled as the rest of us with the Unity GUI interface. You need to click the Ubuntu logo to search for the desired application or else change your window manager to a more classic one.

      Delete
    8. I had followed the instruction COMMAND_START_GNOME="gnome-session --session=gnome" as stated in above, and it works.
      The ubuntu changed the default window manager in 11.10 to unity. This made the display of freenx different.

      Delete
  3. I tried this on 12.04 64bit and unity didn't load successfully, KDE works fine but i couldn't make GNOME to run, I have tried unity unity 2d and classic GNOME and thus far I have not been successful.

    ReplyDelete
    Replies
    1. NX server does not support unity 3D. I guess you computer comes with 3D graphics support, in that case, unity 3D is used by default.

      I have updated the post, added a section to configure NX server to use unity 2D or gnome-shell.

      Delete
  4. I've run the script and it works quite well, but I still can't see the sidebar, even when running ubuntu-2d (and I've made sure my node.conf file has it enabled for COMMAND_START_GNOME). Any ideas?

    ReplyDelete
    Replies
    1. could you post your node.conf here?

      Delete
  5. It's too large to be posted here. Do you have an email I can send it to?

    ReplyDelete
  6. Are you able to make printing and sharing folders work? I followed the steps above, but when I enable folder sharing, I get an error like this: Info: Share: '//computername/sharedfolder' failed to mount: mount.cifs: permission denied: no match for /home/username/MyShares/sharedfolder found in /etc/fstab.

    I can't get the printing to work either...

    ReplyDelete
  7. Thank you so much! This works for me using AMI ubuntu/images-testing/ebs/ubuntu-precise-daily-amd64-desktop-20120516 (ami-4f1d470a).

    I can see sidebar.

    ReplyDelete
  8. Thanks so much for this - it worked first time. Server is 32 bit Ubuntu 21.04, client is Mint 12 running qtnx.
    One thing I didn't do is any of the steps after and including * To configure NX server to use gnome-shell:....

    This was because I'm wary of messing with gnome as doing so has got me very confused in the past.

    Does anyone know if I'm making a big mistake by leaving these last steps out? As I say it seems to be working very well without them

    once again - Thanks :)

    ReplyDelete
  9. Hi! I'm new to freenx-server. I used the bin file, and freenx was successfully installed. Thanks, wilson. The server is running, but client authentication fails. I've tried copying /var/lib/nxserver/home/.ssh/client.id_dsa.key to the client. Anyone has an idea what'll help?

    ReplyDelete
    Replies
    1. I am having the same problem. I have tried regenerating the keys with no luck.

      Delete
  10. Thanks ! The COMMAND_START_GNOME="gnome-session --session=gnome-fallback" totally fixed the issue I was encountering.

    Very appreciated.

    ReplyDelete
  11. Any idea what commands/permissions need to be changed to give all users access to NX?

    ReplyDelete
  12. I have been beating my head half a day trying to solve authentication failure. It appears the .bin self=-extracting is more of an upgrade and does not do a fresh install. For example it did not create a linux user nx with proper home folder and startup,

    I created an nx user by looking at a system with a working nomachine version of NX. Now it has moved to next step, user authentication with "authentication failed for user bob". So my bet ir's missing other nx setup, such as nx users.

    I still don't have it working. Normally I use nomachine that is a snap to install/setup.

    ReplyDelete
    Replies
    1. My error details on above error was:
      NX> 200 Connected to address: 192.168.160.71 on port: 22
      NX> 202 Authenticating user: nx
      NX> 208 Using auth method: publickey
      Connection closed by 192.168.160.71

      I checked and key matches.

      Delete
    2. The reason is: The default nomachine-key does not work any more.

      You need to generate your own key pair to solve the problem, run the following commands as root:

      sudo rm -fr /usr/NX/home/nx/.ssh
      sudo /usr/NX/bin/nxsetup --install
      "Do you want to use your own custom KeyPair? [y/N]" Answer y

      it will generate new key pairs, the /usr/NX/home/nx/.ssh/client.id_dsa.key file is the one you need to distribute to your nx clients. And you need to restart the freenx server:
      sudo /etc/init.d/freenx restart

      In the nomachine nxclient (or opennx client), you need to import the key file client.id_dsa.key (or simply copy & paset the content of the file into the ssh key field.).

      Now you should be able to authenticate through nxserver.

      Delete
    3. The self-extracting bin file does work. I tried today with a fresh installation of Ubuntu 12.04.1. It works except the authentication failure. (Solution has been added.)

      NOTE: you need to run the bin file as root so that it can create nx user and generate other settings.

      Delete
  13. Hey Anonymous! That worked! Thanks so much, I stuggled on that for hours.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. This comment has been removed by the author.

    ReplyDelete
  16. Thanks for your script.... but....

    Please update it, some versions of filexxxx.i386.tar.gz are not up to date.

    Thanks.

    Igor

    ReplyDelete
    Replies
    1. Try use the freenx.bin instead of the script.

      http://www.mediafire.com/download.php?j2lmtoikcz2mv4j

      Delete
  17. This comment has been removed by the author.

    ReplyDelete
  18. I'm getting the following error in the ssh log when trying to start a client after having installed the bin on an Ubuntu 10.10 box:

    usr/NX/bin/nxserver: line 562: kill: (27800) - No such process

    Anyone know what is going on here?

    ReplyDelete
    Replies
    1. the script tested on 11.10 and 12.04 Ubuntu, if you are running Ubuntu 10.10, please see the other guide:

      http://notepad2.blogspot.com.au/2011/05/install-freenx-server-on-ubuntu-1004.html

      Delete
  19. Help please :
    I can't finish the script, I get :

    You can change this behaviour in the /usr/NX/etc/node.conf file.
    Have Fun!
    --2012-12-06 05:02:33-- http://computingplugs.com/files/nxserver
    Résolution de computingplugs.com (computingplugs.com)... 98.155.252.46
    Connexion vers computingplugs.com (computingplugs.com)|98.155.252.46|:80... échec: Connexion terminée par expiration du délai d'attente.
    Nouvel essai.

    Seems that computingplugs.com doesn't get the nxserver ???

    How to finish the install please ?

    Regards.

    ReplyDelete
    Replies
    1. Try use the freenx.bin instead of the script.

      See


      Update(5 May 2012): Easy installation using the all in one binary section

      http://www.mediafire.com/download.php?j2lmtoikcz2mv4j

      Delete
  20. I love using NX to remotely access Ubuntu boxes, but one thing that drives me nuts is that Ubuntu will not allow any NX user to run any administrative apps, such as users-admin (add/change users), or synaptic. I think it is because Ubuntu thinks an NX login is not a secure connection. I posted a message on the huge Ubuntu forum but it seems no one even heard of NX.

    Has anyone else had the above problem on Ubuntu? I think it has to do with the 'tty' not being in a list of secure terminals someplace on the system. Some systems allow a workaround of "gksu users-admin", but on other Ubuntu's even that won't work.

    ReplyDelete
    Replies
    1. NX is over ssh protocal. As long as the user has privilege, you should be able to run

      sudo useradd -m wilson

      or

      sudo usermod -s /bin/bash wilson

      in a terminal.

      Delete
  21. Yes I am aware that old style command line useradd works OK. It is Gnome-based graphical programs such as Synaptic, users-admin and others that don't work. It has to do with Linux not recognizing the terminal 'tty' as a secure port. In the old days there was a /etc/securetty file that one could list terminal ID's that should be considered secure for admin. That went away with newer versions. I think it now has something to do with "policy".

    ReplyDelete