Do you use both Windows and Linux? Wish you could remote into Windows from Linux (Ubuntu or other distributions) or into Linux from Windows? Well, you can. Just like when using a Remote Desktop Connection between Microsoft platforms (or remoting between Linux machines), you can bring up the desktop of the other platform. You can click around the desktop and run applications just as if you were sitting in front of the computer.
We’ll discuss a few different approaches you can take to get this remote desktop capability. Plus we’ll go step-by-step through setting up one method, using free tools. Let’s get started.
Choosing a remote desktop protocol
Remote desktop applications typically use either the Remote Desktop Protocol (RDP) or Virtual Network Computing (VNC) protocol. In order to establish a remote connection, both the host/server and client have to support the same protocol. The problem is that not all operating systems (OSs) use the same default protocol. Plus some Linux distributions and some Windows editions don’t include both a remote desktop server and client application, or either one.
Your first task should be evaluating which protocols are already supported by your computers. In addition to scouring your OS, searching documentation, and referring to the cheat sheet table, you ought to be able to figure out what’s what, and where. Then in the end, you should choose a protocol to use among all your computers.
Platform |
Protocol |
Client |
Server |
Windows Home Edition |
RDP |
X |
|
Windows XP Professional |
RDP |
X |
X |
Windows Vista Home Basic & Premium |
RDP |
X |
|
Windows Vista Business & Ultimate |
RDP |
X |
X |
Most Linux Distros |
VNC |
X |
X |
Here are a few more things for you to consider:
-
VNC remote desktop connections are typically slower than RDP connections, however VNC is usually easier to implement across a variety of platforms.
-
For better performance and security, you can use NoMachine’s NX free server and clients, or those from FreeNX—more advanced configuration is required though.
-
It’s also possible to support RDP connections to Linux machines; for example, by using the xrdp server.
Before we go through the steps for connect to or hosting remote connections, you need to configure your firewall software. On the computers (hosts) that you’re going to remotely connect to, you need to allow the VNC or RDP traffic through the firewall.
In Windows, when starting the server, you should be prompted to Block or Unblock the remote desktop server application. If you hit Unblock, all the work should be done. If you didn’t receive the prompt, you can bring up Windows Firewall and add the Exception manually, using the port numbers listed in a moment.
In Linux, you’ll probably have to manually add an incoming rule to the firewall utility, on the host computer. If needed, you can browse through the menus and do some Googling to figure out how to configure the firewall. Your Linux distro may include a GUI for the firewall or you may have to use the command-line. Either way, add an exception or rule to allow traffic on the appropriate ports, given below.
- RDP uses TCP port 3389
- VNC uses TCP port 5900+ (Each remote connection to a server uses a different port; display 1 uses 5901, display 2 uses 5902, etc) It’s best to define a port range when creating the firewall rule or exception, such as 5900 – 5905.
Now you’ll be able to remotely connect among the computers on your local network. To remotely connect over the Internet, you must configure your router. We’ll discuss this in the next part.
Using Ubuntu’s VNC client and server
If you are using Ubuntu, you already have a VNC client/server installed and ready to use. (This how-to is based on Ubuntu Desktop 8.10 Intrepid Ibex.) To host a remote connection, simply select System > Preferences > Remote Desktop. On the dialog box, configure the desired sharing and security settings. A command/address is listed for you to use if connecting from other computers, on the local network, loaded with Ubuntu or another Linux distro.
To use the VNC viewer on Ubuntu, click Applications > Accessories > Terminal. If connecting to another Ubuntu computer, type the command given by Ubuntu. If connecting to a different Linux distro, the same format applies: vncviewer ComputerNameOrIP:#, such as Figure 1 shows. This consists of the command, vncviewer, followed by the name or IP address of the computer (or the Internet IP when connecting through the web), ending with a colon and the tunnel ID. If connecting to a Windows PC, omit the colon and display number; just type vncviewer ComputerNameOrIP.
If you are using a Linux distro other than Ubuntu, search through its repositories for appropriate packages. Otherwise, you can download TightVNC directly from their website and follow the instructions to build and install it.
The TightVNC/RealVNC server doesn’t have a GUI; you must use the command-line—don’t fret, it’s easy. Simply open Terminal, type vncserver, and hit Enter. The first time you run this, you’ll be prompted to create a password for the VNC connections. Once you define your password, it will automatically configure a display or tunnel, such as shown in Figure 2. Multiple displays are supported in order to offer access for multiple users and/or to define varying attributes, such as screen resolution, startup commands, and more. Each time the vncserver command is run, it creates a new tunnel, typically starting with 1 and incrementing from there on.
Here are several vncserver options to keep in mind:
-
For help, use -help or enter man vncserver.
-
Using -name desiredname gives you the option of naming the particular tunnel or display, which is viewable in the title bar of VNC clients when remoting to the display.
-
Amending :# lets you manually define the tunnel or display number
-
Using -geometry WxH lets you set the desktop width and height.
-
Adding -depth # lets you set a color depth of 8 to 32 bits per pixel.
-
To close a VNC tunnel, use -kill :#, replacing the pound sign with the desired tunnel ID.
Depending upon your particular Linux distro and the VNC solution you have installed, you may or may not have a GUI for the client or viewer application. If you have one, feel free to use it; otherwise you can use the command-line.
For the GUI, you can usually set the options from a dialog box. When connecting to a Linux machine, type in the computer name or IP address of the remote machine (or the Internet IP when connecting through the web) followed by a colon and the display or tunnel ID, and then hit Enter. For instance, ericslinuxbox:1 or 192.168.0.122:1. If connecting to Windows, don’t include the colon and display number. To connect from the Terminal, type vncviewer and the same type of host info, such as shown in Figure 1 earlier.
Loading a VNC client/server onto Windows
TightVNC also offers a Windows version of their VNC client and server from their download page. After you install TightVNC, you can start the server by clicking the Launch TightVNC Server shortcut from the Start menu. The properties dialog (see Figure 3) will appear, where you should assign a password for incoming remote sessions. After reviewing the other settings, hit OK. The icon will appear in the system tray and the server is ready for remote connections. Again, don’t use the colon and display number when connecting to a Windows PC, from any platform.
If you want to connect to a remote PC from Windows, click the TightVNC Viewer shortcut from the Start menu. Just like when connecting from other platforms, type in the name or IP address of the remote PC (or the Internet IP when connecting through the web), and when connecting to Linux boxes, include the colon and a display number.
Stay tuned for the next part: we’ll secure the VNC connection and configure everything for connections over the Internet.
Eric Geier is an author of many computing and networking books, including Home Networking All-in-One Desk Reference For Dummies (Wiley 2008) and 100 Things You Need to Know about Microsoft Windows Vista (Que 2007).
This article was first published on LinuxPlanet.com.