Team LiB
Previous Section Next Section

Hack 31. Run Your Desktop over the Internet

You can access your desktop system and run graphics applications from remote systems at close to full speed, even over dial-up connections.

You might want to access a desktop computer remotely for numerous reasons. Perhaps you are travelling and you forgot an important file on your home machine. You need to edit it, but the application you need isn't on your laptop. It would be nice to connect to your home machine over the Internet, edit the file using software on the desktop, and then transfer the file to your laptop. A number of technologies are available for running applications from remote locations, or remotely sharing desktops; the X Window System has built-in network transparency that allows you to run applications on one machine and display them on another [Hack #32], and the different versions of the VNC protocol allow you to use the desktop on another machine [Hack #30] ). Though each method has its purpose and excels at what it does, both also have one drawbackthey require significant bandwidth. Remote X applications or VNC desktops are pretty slow, even over a DSL or cable modem connection.

NX, from NoMachine (http://www.nomachine.com), is an add-on to X that accelerates remote X applications and can be used to run a full remote desktop at near-native speeds, even over a 56K modem connection. NX works much like a proxy cache for the X protocol, caching and compressing requests and responses to and from the X client and server. This dramatically reduces the network traffic of the X protocol and works in a way that is transparent to the X client. All the NX libraries and components are open source, as is the NX client software. However, the servers NoMachine provides are proprietary, although a free trial period of the personal edition is available, which allows single-client access. In addition, the FreeNX project uses the open source NX libraries to create an open source NX server. The following examples use the personal server and client software from NoMachine.

4.11.1. Installing the NX Server and Client

On the machine on which you want to run the remote session, you need to install an NX server and client. Packages for various flavors of Linux are available from http://www.nomachine.com. Download the NX Server Personal Edition for your distribution, along with a client, and install both in the normal way. For example:

foo@bar:~# rpm -i nxserver-1.4.0-99.i386.rpm
foo@bar:~# rpm -i nxclient-1.4.0-75.i386.rpm

On the machine on which you want to display the remote session, you need to install the NX client. Clients for Linux, Mac OS X, and Windows are available from the same web site as the server.

4.11.2. Setting Up the NX Server

Once NX is installed, you can start the NX server using this command (run as root):

foo@bar:~# /usr/NX/bin/nxserver -start

Now you need to add user sessions to the server using this command:

foo@bar:~# /usr/NX/bin/nxserver --useradd username

where username is the name of a preexisting user on the server system. Next you are prompted to set a password for this session. Once that's done, you can connect your client machine to the server using the NX client. Go to a separate machine and run the client using this command:

foo@bar:~# /usr/NX/bin/nxclient

For the first connection this starts a wizard to collect the connection details. On the second wizard page you can give the session a descriptive name, enter the NX server IP address, and select the type of connection between the client and server.

On the third wizard page, you can choose your protocol type (the NX client is also an RDP and VNC client), the type of desktop session to run the NX server, and the size of the window to display the remote desktop. If there are firewalls [Hack #81] and you only have Secure SHell (SSH) access, check the "Enable SSL encryption of all traffic" box, as this tunnels all communication through SSH (i.e., you only need port 22 open) and has the added bonus of encrypting all the NX traffic. If you don't want to tunnel the traffic over SSH, you'll need to open ports 1000, 5000, and 7000 for the first session, 1001, 5001, and 7001 for the second session, and so oni.e., three ports for each session started.

Finally, on the fourth wizard page, you can choose to create a desktop shortcut for this session and edit the advanced configuration. Once the wizard is finished, you should have a connection dialog with the Login and Session details filled in.

Now type in the password you set on the NX server and click Login. Once this connects and authenticates you should have a complete remote desktop in a window on your client machine.

4.11.3. Further NX Server Commands

Now that you know how to create a basic connection, a few other useful commands for the NX server might interest you. These commands need to be run as root. To see a list of all NX users, type this command:

foo@bar:~# /usr/NX/bin/nxserver --userlist

To delete an NX user (this deletes the user from NX, not as a user of the system), issue the following:

foo@bar:~# /usr/NX/bin/nxserver --userdel  username

where username is the name of the NX account you want to delete.

Paul Cooper

    Team LiB
    Previous Section Next Section