VNCOverSSH

Differences between revisions 7 and 8
Revision 7 as of 2006-02-07 05:49:02
Size: 10756
Editor: adsl-210-74-60
Comment:
Revision 8 as of 2006-02-25 18:41:37
Size: 10929
Editor: adsl-20-182-230
Comment: consistency, quality, and local resources table---jbs
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
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.  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.
Line 16: Line 16:
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: 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:
Line 22: Line 22:
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: 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:
Line 43: Line 43:
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: 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:
Line 53: Line 53:
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.  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.
Line 59: Line 59:
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: 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:
Line 68: Line 68:
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: 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:
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. 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 Xubuntu, 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 103: Line 103:
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. 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.
Line 108: Line 108:
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: 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 114: Line 114:
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: 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 123: Line 123:
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 a similar manner as VNC for additional security. Though some applications may lack the '''-via''' option which '''vncviewer''' uses, there are ways to manually create SSH tunnels for almost any application. See the '''Resources''' for more information. 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 a similar manner as VNC for additional security. Though some applications may lack the {{{-via}}} option which {{{vncviewer}}} uses, there are ways to manually create SSH tunnels for almost any application. See the '''Resources''' for more information.
Line 132: Line 132:
 * '''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
 
||<style="background:#F1F1ED;">{{{man ssh}}}|| System manual page for the {{{ssh}}} application||
||<style="background:#F1F1ED;">{{{man sshd_config}}}|| System manual page for the OpenSSH server configuration file,{{{/etc/ssh/sshd_config}}}||
||<style="background:#F1F1ED;">{{{man vncserver}}}|| System manual page for the {{{vncserver}}} application||
||<style="background:#F1F1ED;">{{{man vnc.conf}}}|| System manual page for the VNC configuration file, {{{/etc/vnc.conf}}}||
||<style="background:#F1F1ED;">{{{man vncpasswd}}}|| System manual page for the {{{vncpasswd}}} application||

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 Xubuntu, 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 a similar manner as VNC for additional security. Though some applications may lack the -via option which vncviewer uses, there are ways to manually create SSH tunnels for almost any application. See the Resources for more information.

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

System manual page for the ssh application

man sshd_config

System manual page for the OpenSSH server configuration file,/etc/ssh/sshd_config

man vncserver

System manual page for the vncserver application

man vnc.conf

System manual page for the VNC configuration file, /etc/vnc.conf

man vncpasswd

System manual page for the vncpasswd application

WWW Resources

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

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

[http://www.ift.uib.no/IT/howto/remote_desktop/vnc.html Information on the vncviewer -via option]

[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)