VNCOverSSH

Differences between revisions 5 and 6
Revision 5 as of 2006-02-07 00:07:11
Size: 11560
Editor: adsl-210-74-60
Comment:
Revision 6 as of 2006-02-07 05:40:39
Size: 10454
Editor: adsl-210-74-60
Comment: Andrew Jorgensen's excellent -via parameter suggestion implemented!
Deletions are marked like this. Additions are marked like this.
Line 78: Line 78:
Now, the commands required at both ends to start a session. In the example presented below, the remote computer is actually using an xubuntu-desktop, and is thus using the XFCE desktop environment. Information will be provided to make use of a standard Ubuntu installation with Gnome as well. The example user will be ''jimi'' and the remote server will be ''82.211.81.166'', with a hostname of ''hendrix''. Remember to substitute your values accordingly though. Now, the commands required at both ends to start a session. In the example presented below, the remote computer is actually using an xubuntu-desktop, and is thus using the XFCE desktop environment. The example user will be ''jimi'' and the remote server will be ''82.211.81.166'', with a hostname of ''hendrix''. Remember to substitute your values accordingly though.
Line 108: Line 108:
On the client computer, you must establish a SSH tunnel to the server computer. This is done simply enough, with the '''ssh''' command, and specifically, the '''-L''' parameter. Use a terminal instance to issue the following command at the terminal prompt: To connect to the server's VNC desktop, from the client you'll simply use the '''-via''' parameter of the '''vncviewer''' command. The syntax of the command then resembles the following when using our example host information from above:
Line 110: Line 110:
{{{ssh -L 5900:127.0.0.1:5901 jimi@82.211.81.166}}} {{{vncviewer -via 82.211.81.166 hendrix:1}}}
Line 112: Line 112:
Remember to use ''your values'' in place of the example values above! For all intents and purposes, this command will behave as a typical ssh login. Enter your password when prompted, and here is what the command proceeds to do: This tells VNC to forward the connection to the server computer (''hendrix'') via the server computer's external, or public facing IP address, ''82.211.81.166'' (a valid, resolvable hostname would work here too).
Line 114: Line 114:
A tunnel is established, so that all connection requests to port '''5900''' on the loopback interface, '''127.0.0.1''' (localhost) of the '''client''' computer will be forwarded to port '''5901''' on the '''server''' computer through the SSH connection which was just made. This is the tunnel. Keep this connection alive, and proceed to the actual VNC connection. Upon entering this command at a terminal prompt, you'll notice some VNC-specific information on screen, and then you'll be prompted for the ''SSH'' password. Enter the SSH password, and upon correctly doing so, the SSH tunnel will be established. Next, you'll receive a prompt for your VNC password (which may, or may not be the same as the SSH password) which resembles the following:
Line 116: Line 116:
=== Making The Connection === {{{
VNC server supports protocol version 3.3 (viewer 3.3)
Password:
}}}
Line 118: Line 121:
To connect to the server's VNC desktop, you'll perform a connection which at first does not seem sensible, until you fully understand what is happening with the tunneling arrangement as explained above. Using the ''Terminal Server Client'' application, or the '''vncviewer''' command-line application, you need to open a connection to the IP address '''127.0.0.01'''. That's right, to "yourself", or the loopback IP. Enter the VNC password, and you should then see remote server's desktop appear!
Line 120: Line 123:
What happens next, provided all is setup and working properly, is that the connection to '''127.0.0.1''' on the default VNC port ('''5900''') gets automatically forwarded over the ssh tunnel to the server computer at '''82.211.81.166''' where the VNC server is listening on port '''5901'' resulting in a connection to the server computer's X desktop as launched by the VNC server application! The connection traveling over the Internet is encrypted, and secure, just like any SSH connection, so there is no need to worry about plain-text passwords being transmitted in the clear while logging into the VNC session, or the session data itself being broadcast in the clear over the Internet!

now that you have the basic connection working, you should study more information via the resources in the '''Resources''' section of this guide, and remember that virtually any kind of applications which communicate via TCP may be forwarded over SSH tunnels in the exact same manner as VNC for additional security.
Now that you have the basic connection working, you should study more information via the resources in the '''Resources''' section of this guide, and remember that virtually any kind of applications which communicate via TCP may be forwarded over SSH tunnels in the exact same manner as VNC for additional security.

Introduction

This brief guide will introduce a method for securely accessing the desktop of a remote Ubuntu computer system from a local Ubuntu computer system by tunneling a Virtual Network Computing (VNC) session over the Secure SHell (SSH) protocol. This guide does not use the default installation of the Vino VNC server provided with Ubuntu, nor does it utilize any of the server-specific Remote Desktop functionality provided by the Preferences menu. This guide uses the TightVNC flavor of VNC for the server side, and is applicable to either standard, or server installations of Ubuntu.

Target Audience

This guide is for anyone with sufficient experience with the GNU/Linux command-line, and particularly experience in executing command-line utilities, and editing system configuration files with a preferred editor. A familiarity with OpenSSH, and VNC will help in understanding the concepts involved, but is not necessary to follow this guide's instruction.

VNC

Virtual Network Computing (VNC) is a freely-available, cross-platform software solution which makes viewing, and interacting with a remote computer's desktop possible from any other computer, or appropriately enabled device across a Local Area Network, (LAN) via the Internet. The solution is comprised of separate server, and client applications, but control via a standards-compliant web browser which supports JavaScript is also possible too. More information on VNC is available via the [:InterWiki:VNC Wiki Page], or the Resources section of this guide.

Installing VNC Components

Before you can begin establishing the secure desktop connections with VNC, you must verify installation of the appropriate packages on the server, and client computers.

The Host Computer (Server)

To install the TightVNC software on your Ubuntu server computer, (the remote computer) simply use your preferred package manager application, such as Synaptic, and install the vnc-common and tightvncserver packages. To install these packages from the terminal, open a Terminal instance, and type the following command at the terminal prompt:

sudo apt-get install vnc-common tightvncserver

Enter your user password when prompted, and provided your system's package sources are in order, the packages should install without error.

To avoid a nasty error related to FontPaths when starting your VNC server later, edit the the /etc/vnc.conf file with sudo, and your preferred editor, and add these lines to the very bottom of the /etc/vnc.conf file:

$fontPath "unix/:7100" # local font server
# if the local font server has problems, we can fall back on these
$fontPath .= "/usr/share/X11/fonts/misc,";
$fontPath .= "/usr/share/X11/fonts/cyrillic,";
$fontPath .= "/usr/share/X11/fonts/100dpi/:unscaled,";
$fontPath .= "/usr/share/X11/fonts/75dpi/:unscaled,";
$fontPath .= "/usr/share/X11/fonts/Type1,";
$fontPath .= "/usr/share/X11/fonts/CID,";
$fontPath .= "/usr/share/X11/fonts/100dpi,";
$fontPath .= "/usr/share/X11/fonts/75dpi,";
# paths to defoma fonts
$fontPath .= "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType,";
$fontPath .= "/var/lib/defoma/x-ttcidfont-conf.d/dirs/CID";

Save the file, and exit the editor.

The Remote Computer (Client)

As of this writing, Ubuntu version 5.10 "The Breezy Badger" ships with the VNC viewer application (vncviewer) installed by default. A Terminal Server Client application is also provided which gives a front-end to the vncviewer command. To verify installation of the Terminal Server Client, simply click the Applications Menu, then navigate to the Internet Menu, where you should observe the Terminal Server Client entry. To verify installation of the vncviewer application, open Terminal window, and enter the following command at the terminal prompt:

which vncviewer

The output of the command should resemble the following:

/usr/bin/vncviewer

Once you've installed the VNC server software on the server computer, and verified installation of the VNC client software on the client computer, you are ready to proceed to OpenSSH installation on the two computers.

SSH

OpenSSH is the freely available version of the Secure SHell (SSH) software which allows for direct remote terminal control, file transfer, and tunneling all over a secure, and encrypted connection. Additional information about OpenSSH is available from the [:InterWiki:SSHHowto Wiki Page], the [:InterWiki:AdvancedOpenSSH Wiki Page], and the Resources section of this guide.

Installing OpenSSH

Installation of the OpenSSH client, and server components is identical for both the client, and server computers. Using your preferred package management application, install the openssh-client and openssh-server packages. To install these packages at a terminal prompt, open a Terminal instance, and type the following command at the terminal prompt:

sudo apt-get install openssh-client openssh-server

Enter your user password when prompted, and provided your system's package sources are in order, the packages should install without error.

Once you've installed OpenSSH on the client, and sever computers, it is time to make a secure, tunneled VNC connection over SSH!

VNC + SSH

Creating the VNC connection over a SSH tunnel is quite simple, but involves issuing commands at both the client and server computers. To do this, you must have physical access to both machines, or use the ssh application itself to login at the remote computer from the local computer, using a syntax similar to the following:

ssh remote.host.name.com

or

ssh 82.211.81.166

to connect via IP address. Of course, you should replace the example hostname, or IP address in the commands above with your remote computer's actual hostname or IP address. Provide the password of your account on the remote machine to complete the ssh login.

Now, the commands required at both ends to start a session. In the example presented below, the remote computer is actually using an xubuntu-desktop, and is thus using the XFCE desktop environment. The example user will be jimi and the remote server will be 82.211.81.166, with a hostname of hendrix. Remember to substitute your values accordingly though.

The Host Computer (Server)

To enable a listening VNC server on the server computer, enter this command into a terminal prompt:

vncserver :1

The first time you do this, you'll be prompted for a password to use for incoming connections:

You will require a password to access your desktops.

Enter, and verify the password you wish to use to access the server's desktop from the client computer.

You should then see startup messages from the VNC server similar to the following:

New 'X' desktop is hendrix:1

Creating default startup script /home/jimi/.vnc/xstartup
Starting applications specified in /home/jimi/.vnc/xstartup
Log file is /home/jimi/.vnc/hendrix:1.log

Notice the references to the xstartup file? This file controls what is launched during the X session started by VNC in terms of X applications, and the Window Manager, or X Desktop Interface (Gnome, KDE, XFCE). It is configured to take sensible defaults from the currently configured X Desktop Interface, or Window Manager, so it should not need additional editing. However, if the X session as started by the VNC server does not behave as you wish it to, the ~/.vnc/xstartup file may be used to force a particular behavior.

Now that the VNC server is running, we proceed to the "tricky" part, which is to establish our tunnel, and connect over it.

The Local Computer (Client)

To connect to the server's VNC desktop, from the client you'll simply use the -via parameter of the vncviewer command. The syntax of the command then resembles the following when using our example host information from above:

vncviewer -via 82.211.81.166 hendrix:1

This tells VNC to forward the connection to the server computer (hendrix) via the server computer's external, or public facing IP address, 82.211.81.166 (a valid, resolvable hostname would work here too).

Upon entering this command at a terminal prompt, you'll notice some VNC-specific information on screen, and then you'll be prompted for the SSH password. Enter the SSH password, and upon correctly doing so, the SSH tunnel will be established. Next, you'll receive a prompt for your VNC password (which may, or may not be the same as the SSH password) which resembles the following:

VNC server supports protocol version 3.3 (viewer 3.3)
Password:

Enter the VNC password, and you should then see remote server's desktop appear!

Now that you have the basic connection working, you should study more information via the resources in the Resources section of this guide, and remember that virtually any kind of applications which communicate via TCP may be forwarded over SSH tunnels in the exact same manner as VNC for additional security.

Have fun with your secure, encrypted desktop sessions!

Resources

Additional information on VNC, and SSH is available via the following resources:

Local System Resources

  • man ssh - manual page for the ssh application

  • man sshd_config - manual page for the OpenSSH server configuration file,/etc/ssh/sshd_config

  • man vncserver - manual page for the vncserver application

  • man vnc.conf - manual page for the VNC configuration file, /etc/vnc.conf

  • man vncpasswd - manual page for the vncpasswd application

WWW Resources

[http://www.openssh.org OpenSSH Website]

[http://www.tightvnc.com/ TightVNC Website]

[http://www.ccs.neu.edu/howto/howto-sshtunnel.html SSH Tunneling HOWTO @ Northeastern University]

[http://www.revsys.com/writings/quicktips/ssh-tunnel.html SSH Tunneling Made Easy]

[http://www.linuxplanet.com/linuxplanet/tutorials/6155/1/ Using VNC Tunneling over SSH]


CategoryCleanup

VNCOverSSH (last edited 2008-08-06 17:00:00 by localhost)