Open Source

Tech Tip: Connect to a remote machine using TightVNC

Learn how to set up a VNC server on a Linux machine.

Virtual Network Computing (VNC) is a cross-platform standard that allows you to connect to a remote machine using a graphical interface. With VNC, you can use one Linux machine to view the desktop of another Linux machine—in fact, you can even use a Windows or Mac machine to view a Linux machine and vice versa. Although the software may be different on each platform, the ability to view remote desktops is the same.

VNC can be useful in several situations. For example, if you run a headless machine somewhere on your local LAN, you can connect to a graphical desktop rather than using ssh for a purely command-line experience.

But VNC has its drawbacks. For one, it isn't very secure. So if you want to connect to a remote machine using VNC, it would be wise to use an ssh tunnel to encrypt and protect your session.

Most Linux distributions come with TightVNC. This software is both a VNC client and server. To set up a VNC server on a Linux machine, install the tightvnc-server or vncserver package.

The names may vary depending on your distribution. For example, on a Mandrakelinux system, you can configure the VNC server by editing /etc/sysconfig/vncservers and adding lines to determine which VNC servers to start. (You can enable more than one at a time.)

It's worth noting that a VNC server binds to a particular X interface, so only one user can use it. To access a desktop as user joe on the first X interface, modify the vncservers file to add the following:


Next, you need to define a password for joe, and you can use the vncpasswd program to accomplish this. Run it as user joe, and supply the chosen password when it prompts you.

After setting the password, you can start the VNC server by executing the following:

# service vncserver start

To connect to the VNC server from another Linux machine, run the vncviewer program. To connect to joe's desktop, execute the following:

$ vncviewer host:0

Replace host with the hostname or IP address of the machine to which you want to connect. After you supply the password, a new window will open that allows you to control the desktop.

If you terminate the VNC session, the desktop remains as is until you either stop the VNC server or reconnect.

Editor's Picks

Free Newsletters, In your Inbox