Connect to a remote Linux desktop with x11vnc and Gtk VNC
Being able to do remote administration is crucial to many system administrators. And there are plenty of tools available for this job. You can use command line tools and full-blown GUI tools. Of course many users prefer to do things as simply as possible. Fortunately Linux has the right tools to make such a task simple. The ability to do graphical remote desktop administration is just a matter of having the vnc server running on the target machine and then running the desktop viewer on the local machine.
In this article I will show you how to take control of a remote Linux desktop with the help of x11vnc, Remote Desktop Viewer, and secure shell. You will, of course, have to have secure shell access to the remote machine. Other than that you have everything you need. So let's get to work.
You will need the following installed in order to take on this task.
- VNC client (such as gtk vnc)
- Ssh client (openssh works fine)
- Ssh server (openssh-server works great)
- VNC server (x11vnc is my recommdation)
Fire up your package management tool, search for the above applications, and install each. If you do not already have the secure shell server installed on the remote machine, you will need physical access in order to install the tools. If you already have the ssh server installed you can simply ssh to the remote machine and install the VNC server from command line (such as sudo apt-get install x11vnc) Once you have these installed you are ready to start setting up your connection.
The first thing you need to do is secure shell to the remote machine (we'll say the remote machine is at IP address 192.168.1.10) and start up the VNC server. From the command line (on the remote machine) you will enter the command x11vnc. This will start the VNC server but you will not get your bash prompt returned to you. To have your VNC server running at all times you could add the line:
to the end of your /etc/rc.local
The Client Machine
For the purposes of this tutorial I will use the Gtk VNC Viewer. It is a very simple to use, up to date, client. You will find this tool in Applications > Internet. When you first start it up you will see a fairly straight-forward connection window. You only need enter:
- IP Address:Port: IP address and port of the remote machine (in the form of 192.168.1.10:5900). NOTE: x11vnc uses port 5900 by default.
- User name: The user name you will connect with on the remote machine.
- Password: Password of the user on the remote machine.
If you know the above information is correct (and you know you'll be connecting to this machine again) click the Add button to add the remote machine (as shown in Figure 1).
To connect to the remote machine either enter the information in the text areas and click the Connect button or double click on a saved machine from the list.
When you connect a new, maximized window will open showing your remote desktop (see Figure 2). From this window you can do the following:
- Disconnect: Disconnect from the remote machine.
- Send keys: Send key-combinations to the remote machine.
- Fullscreen: Switch to a full screen window.
- Screenshot: Take a screen shot of the remote desktop.
- Make icon on desktop: Create an icon that allows you to connect to this remote desktop with a double-click.
You can now interact with this remote machine as if it were your own desktop.
Taking advantage of the remote desktop is a great way to train users or trouble shoot problems on a remote machine. I use this exact setup for a number of clients. It works well.Advertisement