How to install NX server and client under Ubuntu/Kubuntu Linux

NOTE: This post has been updated to include information from reader comments, see above. The following was imported from my old blog and is here only because the original comments are attached.

If you have ever tried to access a Ubuntu/Kubuntu Linux system using VNC, and your host computer wasn’t particularly fast, you may have noticed that things slow down considerably – you definitely know you’re accessing the computer remotely, even if the access is via a local network link. You may have heard about FreeNX and decided to try it, but if you are like many folks you may never have gotten it to work (or if it did work, it didn’t work in quite the expected manner).

However, you can install the NX Free Edition server and client from Nomachine and it works great! The problem is that it’s not in the Ubuntu repositories, so many people shy away from it, particularly if they’ve come across any of the bad installation advice that is going around.

In my experience, the installation of the NX Free Edition using the instructions below is a lot easier than the ways that don’t work (that you will find on various web pages), or at least don’t work very well. Here’s how I did it on a Kubuntu (Dapper Drake) box. Before I begin, I must caution you that the bulk of my OS experience is with Windows, and I’m writing this primarly for Windows users that also have a Kubuntu/Ubuntu box. So if I do something in a way other than the way you’d do it, just remember that if you think you’re a Linux expert, you’re not who I’m writing this for.

One other point, note that NX does not work in precisely the same way as VNC – while VNC lets you take control of the current desktop on the target machine, NX lets each login have its own session and desktop. So you could be using your Linux box and let another family member come into it via NX, and each of you would have your own desktop and session.

Please note: These instructions were developed using Kubuntu Drake, and tested on Ubuntu Drake also. A similar setup was attempted under Kubuntu Edgy, which at first failed because the libstdc++2.10-glibc2.2 package had not been previously installed. Even then, my first impression is that NX runs a bit slower under Edgy than it did under Drake, but that may just be my imagination.

1) First, if you have tried to install FreeNX, please uninstall it, along with any other packages you installed solely for the purpose of getting it running. That also applies if you’ve installed any of the Nomachine servers or clients. Search for any NX directories that have been created and delete those (make sure it’s a directory that was actually created during the NX or FreeNX install). This is to clean your system of all traces of the former installation. The same applies to any client software you’ve installed on machines, if it’s not the exact software described below.

2) Using your favorite package installer (such as Adept or Synaptic), install the ssh package and the libstdc++2.10-glibc2.2 package (if these are not already installed on your system). The installation will fail if these packages are not installed.

3) Go to the page at http://www.ubuntuforums.org/showthread.php?t=204976 and follow the instructions in the second message in that thread. Just in case that thread is not accessible to you, I will reprint the body of the pertinent message here. In that thread, user jkbrowne wrote:

Ok, I’ve fought with this off and on for a-while, but I finally found the right combination. First of all, forget freeNX. The NoMachine folks have released a “desktop” edition of their latest product called “NX Desktop Server” that is free for personal use (2 users/connections).Before proceeding, be sure to *completely* remove any previous versions of any of the FreeNX files or libraries. Undo what you have already done, and remove the FreeNX source URLs from your /etc/apt/sources.list.

———————–
Step 1 – Download
———————–

Download “NX Desktop Server DEB for Linux” from:
http://www.nomachine.com/select-package.php?os=linux&id=1

Download “NX Node DEB for Linux” from:
http://www.nomachine.com/download-node.php?os=linux

Download “NX Client DEB for Linux” from:
http://www.nomachine.com/download-client-linux.php

———————–
Step 2 – Install
———————–

Install the DEB files in this order:

nxclient
nxnode
nxserver

I just right-clicked on them and installed them…use apt-get if you prefer.

Let me interrupt jkbrowne’s instructions for a moment to say that some users may prefer to open a terminal window and use the dpkg command, like this:

sudo dpkg -i file/path/filename.deb

(Of course you’d substitute the actual .deb file path and name for the italicized part. Now back to the instructions…)

———————–
Step 3 – Configure
———————–

Load up your /etc/ssh/sshd_config file into an editor:

sudo nano /etc/ssh/sshd_config

Add the following line & save the file
AuthorizedKeysFile /usr/NX/home/nx/.ssh/authorized_keys2

Restart sshd by typing:
sudo /etc/init.d/ssh restart

Verify nxserver is configured properly by typing:
sudo /usr/NX/bin/nxserver –status

This should return:

NX> 900 Connecting to server ..
NX> 110 NX Server is running.

NX> 999 Bye.

If you get any errors here, then something is wrong with your configuration. If not, then NX Desktop Server should be installed.

Before anyone complains, yes, I’m using the NoMachine server key just because it’s easy. If you want to generate your own key, you can. These instructions worked for me on Dapper….YMMV. Let me know if you have trouble…..hopefully my notes were correct.

Good luck!

4) The above instructions are substantially complete for setting up the server. After I followed these, I went to the /usr/NX/etc/server.cfg file and uncommented and edited the following two lines to these values (just in case it’s not clear, please note that the values in the quotation marks are numeric, that is, “1″ is the digit one, and “0″ is the digit zero):

ENABLE_AUTOKILL_SESSIONS = “1″
ENABLE_UNENCRYPTED_SESSION = “0″

And also I uncommented and edited the following line in the /usr/NX/etc/node.cfg file:

ENABLE_UNENCRYPTED_SESSION = “0″

5) Now you will want to set up a client. The client software is also available from the Nomachine site – use the NX Client for Windows (only if installing on a Windows box, of course). If you have seen advice on other sites telling you to use an older version, ignore it – the current client works with the current server! The reason some sites gave that advice is because the FreeNX server in the repositories won’t work with the current client.

You probably do NOT need to download any of the font files on that page, unless you are running some specific software that requires them, which you almost certainly are not (remember what I said about the target audience for this article).

Setting up the client is pretty straightforward. Under the General tab, Desktop section, set it to “Unix” and “KDE” (if you use Kubuntu) or “Gnome” (if you use Ubuntu). Set the slider to the appropriate connection type (probably LAN for most users, where the Kubuntu/Ubuntu box is on your local network). Under Display, set it to “Fullscreen” (for best image quality) and default image encoding.

Under the Advanced tab, check “Enable SSL encryption of all traffic” (if you made the file edits I suggested above).

Under Services, you can try checking “Enable multimedia support” – this MAY allow you to hear sound from the remote box. As this is streamed over the network, don’t expect perfection. And if you use Kubuntu, don’t expect to hear anything. Even under Ubuntu, it appears that the sound plays from some apps but not others. Since I don’t personally use Unbuntu, I’m not sure why the sound plays for some apps but not others, and I don’t know why it seems that it never works under Kubuntu.

Leave the other settings at the defaults and everything should work, except for one thing – any time you press alt-tab or alt-shift-tab, it will switch you to another window on your local machine, rather than allowing you to walk through the windows on your Kubuntu or Ubuntu system.

6) There is a fix for the alt-tab problem: Download and install the NX Client Utility from the page at http://ssrini.netfirms.com/. I strongly recommend you stick to the Release Version 1, rather than Beta Version 2, unless you have some real specific need to run the Beta version. The beta version did not work for me, but the release version did.

Note that in order for the NX Client Utility to work, you’ll have to do the following on your Kubuntu box (I assume there’s a similar way to do this under Ubuntu, but haven’t checked): From the “K” menu, go to System Settings | Regional & Accessibility | Keyboard Shortcuts. Set up alternate key mappings for “Walk Through Windows” and for “Walk Through Windows (Reverse)” – when you set up the mappings you actually press the keys and it sets the mapping to what it receives, so do this when you are connected via the NX Client and with the NX Client Utility running (you have to execute the NX Client Utility separately – it does not start with the NX Client). What you will most likely see is that when you press alt-tab, it will set the alternate key mapping to alt-/ and when you press alt-shift-tab, it will set the alternate key mapping to alt-?.

Of course, once you have the NX Client Utility running and configured, you will not be able to tab out of the NX client to get back to other windows on your local machine, and if you’re running in fullscreen mode it may not be immediately obvious how to get back to Windows. I do it by hitting the Windows key, which takes you back to Windows (appropriately enough), and then hitting the Esc key to make the start menu go away. There may be an easier way, but I haven’t discovered it yet.

7) Shutting down the remote system: For some reason NX (or perhaps Kubuntu) assumes that you will never want to completely power down the remote computer if you are logged in remotely, and therefore they don’t offer the usual option to shut down the computer in the “Log Out” menu. There should be a way around this, but so far I haven’t found an easy way to do it. While you could open a terminal window and issue a simple halt or shutdown command, that has the drawback of leaving the NX session in an unknown state where it probably can’t be recovered, but nevertheless a bunch of information about the session is saved to your hard drive (in fact, you may want to go into the subdirectories of the /usr/NX/var/db directory and clean out the crap relationg to old sessions occasionally – the fact that NX doesn’t clean up this garbage automatically is something I hope they’ll address in future revisions).

So if you really want to power down the computer, open a terminal window and issue the command:

sudo shutdown -h +2

The +2 means “delay shutdown for two minutes” (increase this if you think you need more time). Now log off in the usual manner – after you’ve logged off, the system should power down. Test this to make sure it works as expected. And do bear in mind that once the system has been powered down, you’ll need to power it back up in some manner before you can reconnect, which can be inconvenient if you are not located someplace physically close to the computer.

That’s about all I can think of to mention right now – if I figure out anything else I may edit this. Please note that my knowledge of Linux is fairly limited, so please don’t send me any questions asking me how to do something not specifically within the scope of this article – I am definitely not the Kubuntu/Ubuntu answer man, or anything like that. I just spent way too much time trying to figure out how to set up NX, and wanted to put the information where I could access it again in the future.

19 Comments »

  1. Anonymous said

    This article was great. It helped me a lot and appreciate your efforts in blogging it. I’m just like you: I forget stuff and have to write it down somewhere for future reference. At least you’ve gone the extra step and making those notes available to others online. Thanks again.

  2. Rich said

    Just want to say thanks for posting this. I followed your directions and it all worked first time! Very nice. I am using Ubuntu Dapper Drake 2.6.15-27-386 and can now log in from my Windows XP laptop. Again, thanks!

  3. Jo-Erlend Schinstad said

    When you run NX client in fullscreen, you can minimize it by clicking on the top-right corner of your screen.

    Since NX uses ssh, you can connect to sshd from your other machine and issue sudo shutdown from there, you don’t have to shutdown from within the graphical environment.

    There is a very good reason why a user shouldn’t be able to shut down the system. What if your brother is working on a paper and you shut down the system because you think that’s a good move. If he’s your big brother, you may be in trouble.

  4. Anonymous said

    Great stuff, it just works! Just wanted to let you know that sound in KDE works if KDE use the esound deamon

  5. Wolfram said

    It is a great article.

    I have some additions to the problem of enabling thes password authentication.
    I don’t like password authentication via the internet, even it is encrypted (Brute force attack etc).

    So I have created workaround. For this I use the inetd.conf and a second configuration file for the sshd.

    I also created a “new” service:

    ssh-nx

    /etc/services:
    ssh-nx 23/tcp #local fuer nxserver
    ssh-nx 23/udp #local fuer nxserver

    Then I created two entries in the inetd.conf.

    At first the entry for nx-user. This can only use authentication keys.

    ssh stream tcp nowait root /usr/sbin/sshd sshd -i -4

    The second entry is the entry for the local users on the nxserver machine.

    Here you will see, that there is used another configuration file. It is /etc/ssh/sshd_config.nx. In this config file password authentication is allowed.

    For more security I also have done the following entry:

    AllowUsers: user1@127.0.0.1 user2@127.0.0.1

    So there is no possibility to abuse the sshds.

    And here is the second entry in the inetd.conf:

    ssh-nx stream tcp nowait root /usr/sbin/sshd sshd -i -4 -f /etc/ssh/sshd_config.nx

  6. soop said

    with the free version of it how many people can you have log into a machine?

  7. Aesphades said

    I just wanted to say that this web page was the single most concise explanation of setting up NX I’ve seen. I’m pretty much new to Linux as well, and wanted to use my laptop running Windows to connect to a Kubuntu (6.10) desktop being used as a server (it was previously also Windows). I wanted the speed of remote desktop – needless to say I was disappointed by VNC. Your guide worked perfectly, I cannot thank you enough.

  8. Ross Farinella said

    I administer an ubuntu desktop remotely via ssh and not having a gui can be hard sometimes because I can’t see exactly what my end users see. This is by far the best and easiest way to install NX I and I just wanted to say thanks. I was connected from my Gentoo laptop to the ubuntu desktop in under 10 mins. bravo on the easy how-to

  9. Anonymous said

    I think many of the problems that new users have with getting freenx 0.4.4+0.4.5 to work is a temporary incompatibility with the current nomachines Windows client nxclient 2.1.0.9. I read the mailing list archive which posts a location for old nxclient 1.5.0-114 among others and that works right out of the box. Also the mailing list describes 2 or 3 problems and solutions when using the nxclient 2.x, but I didn’t try to apply those.

    If and when freenx is updated, that will probably fix the current issues with nxclient 2.x.

  10. Anonymous said

    The solution to switch back to the desktop is the “magic pixel” on the top right corner of the running nx session. It is very usefull with the Linux client who doesnt have a windows key on the keyboard…

    http://www.nomachine.com/howto/switch-desktop.php

  11. Vinod Ponmanadiyil said

    Thank you very much for the instructions. I was able to setup the nxserver and clients securely with the help of your instructions.

  12. Anonymous said

    Click the upper right corner of the screen will bring you back to Windows.

    http://www.nomachine.com/howto/switch-desktop.php

  13. Ben said

    Hi, thanks for posting this. Was this an instal, on Ubuntu Edgy? If so how did you get past the missing libstdc++2.10-glibc2.2?

  14. ostrochovskyCUT_THIS_OUT@rec.unibaCUT_THIS_OUT.sk said

    On my system Kubuntu 6.10, nxclient needed to be installed first. Server and node were dependent on it.

  15. Viru said

    Hey thanks very much. My first attempt with your instructions worked right away. Good job.

  16. Anonymous said

    Mate,your a champion.
    Instructions worked fine as of 20/9/07 on Fiesty Fubuntu.
    Please continue to leave setup notes in your blog :)
    Pat
    P.S. Anyone reading this, NX leaves VNC in the dust.

  17. Dan said

    These instructions were very helpful! One problem I ran into was that the instructions change the authorized keys file for all sshd connections, which broke other things. Instead of changing /etc/ssh/sshd_config as suggested, add that line to /usr/NX/home/nx/.ssh/sshd_config and both NX and other connections will work.

  18. Douglas said

    When in fullscreen, click in the upper right corner to switch back to Windows

  19. dtl said

    Hello,

    I wonder if these instructions still apply even for for Hardy or Intrepid?
    Thanks.

RSS feed for comments on this post · TrackBack URI

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 )

Twitter picture

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

Facebook photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 120 other followers