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

One of the main reasons I stopped blogging for a long period of time was because I thought no one was reading my old blog, and the reason I thought that was because I never saw any comments on any of my posts. Well, it turns out that my old blog service didn’t feel that it was necessary to boldly display the fact that there were pending comments that needed to be approved until recently. It turns out that I had 75 pending comments that I knew nothing about until last night.

Strangely enough, the most heavily commented article had nothing to do with VoIP or Broadband. Instead, it was the article with the title above, which I will reprise for you herewith, along with some additional comments. Please note that I am not updating the article (except to add pertinent reader comments), just reposting it because so many people seemed to find it helpful. In particular, note that it was not written with the current versions of Ubuntu/Kubuntu Linux in mind, so let me know in the comments if anything needs tweaking to work in the current versions (I’m assuming that WordPress will actually notify me of pending comments!).

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

NOTE: We interrupt here for this comment from reader “Dan”: “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.” So, instead of the above line, you may want to use:

sudo nano /usr/NX/home/nx/.ssh/sshd_config

Back to jkbrowne’s instructions:

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

[Note that there are TWO dash characters before the word "status" in the above line]

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 (one reader wrote that sound works under KDE if KDE uses the esound daemon – feel free to experiment). Even under Ubuntu, it appears that the sound plays from some apps but not others. Since I don’t personally use Ubuntu, 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. Several readers mentioned that there is a “magic pixel” on the top right corner of the running NX session that you can click to minimize it (especially useful if you don’t have a “Windows” key), see http://www.nomachine.com/howto/switch-desktop.php for details.

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.

Jo-Erlend Schinstad mentioned that 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.

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.

Reader additions

When I originally posted this, several people commented, but as I noted above I never saw those comments until last night. I have incorporated some of those notes into the text above, and here are a few additional notes from readers (I’m omitting the “thank you” notes and such because although they are appreciated, I’d rather not use up all of my alloted storage space on the first post)!

  1. 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
    (Wolfram)

  2. 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. (Anonymous)
  3. On my system Kubuntu 6.10, nxclient needed to be installed first. Server and node were dependent on it. (ostrochovskyCUT_THIS_OUT@rec.unibaCUT_THIS_OUT.sk)

9 Comments »

  1. Thank you for the great post… I know it’s quite old, but Google referred me :)

    I followed the directions here, and had nxserver up an running in about 15 minutes (had to be done over ssh, which slowed me down).

    Prior attempts at installing nxserver took several hours each, as the directions I was following were nowhere near as clear, so I thank you profusely for such concise and useful information!

  2. [...] Following instructions over here. [...]

  3. velchinaski said

    HI
    whether you can connect through this program wifi ?
    I can connect from my iPhone in ubuntu 8.10…please help me if you now how :)
    Thx

  4. Henri said

    Thank you very much, very good tutorial. At first i was afraid to go ahead with this guide, since it looked long. But when i finally did, i got freenx working with first try. Thank you.

  5. yuwen said

    thanks for the information of great help! finally my nx is ok!

  6. Jeff said

    I tried this part and i am not sure on the commands on how to do this?

    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
    (Wolfram)

  7. Jeremy Pyman said

    Very minor issue, but the command to check if the service is running is
    sudo /usr/NX/bin/nxserver –-status
    (note the second dash)

  8. Thanks, jeremy. There actually are two dashes in the raw text, but either WordPress is dropping one of them before displaying the article, or they are just so small that it looks like only one dash. In any case, I added a note under that line to make it clear that there are two dashes there.

  9. Brenda said

    Another way to fix the ssh config is to replace:

    AuthorizedKeysFile /usr/NX/home/nx/.ssh/authorized_keys2

    with:

    AuthorizedKeysFile %h/.ssh/authorized_keys2

    Then everything works as it should.

RSS feed for comments on this post · TrackBack URI

Leave a Comment