HowTo: Remote Access Ubuntu using Firefox
Introduction
This how-to will show you how to make a vnc connection over the internet using firefox on the client. This how-to should work with any java capable browser, including (personal success with) internet explorer.
You can skip the rest of this introduction if you know how to configure your router/firewall.
Warning: The how to installs a (vnc) server and java and is a potential security risk as your Ubuntu box will be potentially accessible to anyone on the internet.
Access over the Internet
First you should strongly consider both a router and firewall.
The most difficult part of allowing internet access to your Ubuntu server may be configuring your router and firewall ... and is the most difficult part of this how-to. Unfortunately this is sometimes difficult to enable and since each situation is unique I can only give some general pointers.
If you do not understand IP addresses and ports you can think of your IP address as a physical address of say an apartment complex.
IP address = your computer = street address
Port = your server = apartment number

Server IP
The IP address of your VNC server is different on a LAN vs an internet connection. Your internet IP address is assigned by your internet provider.
- You can check your IP address here (or elsewhere).
The problem can occur if you use DHCP (rather then a static IP address) the internet IP address can change from time to time, most often when you reboot. Most internet service providers use DHCP.
A potential solution is to register at dyndns, or similar service. dyndns will provide free service.
You can then determine your vnc server IP address (from your client) via ping. ie ping <name_of_dyndns_server>
Router
You can skip this step if you connect directly to the internet.
Assuming you use a router, you must configure your router to forward the correct port(s). The gory details of how to do this vary by router, you will need to refer to your routers manual (if you lost your manual, start with a google search).
You will need to forward ports 5801 and 5901 (from your router to your /ubuntu server). Ports 5801 and 5901 are the default ports for this how-to, although you can use others.
- 5801 to allow the java applet to establish a connection
- 5901 for connection to the VNC server.
Basically you will start the server with a :X The default port is 5800 + X , so with this how to we will be using :1 and a default ports of 5801 and 5901. You will need to specify the 5801 port you are connecting to at the time of connection (in your browser address box). You can start more then one server (ie :2 , :3, etc corresponding to ports 5802 + 5902 , 5803 + 5903, etc).
See man vncserver for more information.
Firewall
This is very easy to do via Firestarter Ubuntu Wiki, a gui front end to IP Tables.
- Be sure to configure firestarter to allow pings.
Open the firestarter gui (Applications -> Internet -> Firestarter)
In the "Policy" tab, under the "Allow service" section, right click anywhere in the white space.
Select "Add rule"
- Under "Port" enter the ports you want to enable (5801 and 5901). "Allow Anyone" unless you know the IP you are connecting from and want to restrict access.
Repositories
You will need to enable the commercial repositories on both Ubuntu server and client.
I do this by adding these lines to /etc/apt/sources.list
Code:
gksu gedit /etc/apt/sources.list
Note: The above repos are for gutsy, you will need to use the commercial repos for your version (ie Dapper, Edgy, Feisty).
Ubuntu Wiki Repositories Ubuntu
Server setup
1. Enable the commercial repos as above.
2. Install by any means vnc-common, tightvncserver, and tightvnc-java
Code:
sudo apt-get install vnc-common tightvncserver tightvnc-java
3. Post-install configuration of the tight vnc server.
- Edit the fonts path in /etc/vnc.conf
Code:
gksu gedit /etc/vnc.conf
- For Feisty/Gutsy (7.04 and 7.10) add these lines jus after all the commented out font lines :
$fontPath .= "/usr/share/fonts/X11/misc,";
$fontPath .= "/usr/share/fonts/X11/100dpi/:unscaled,";
$fontPath .= "/usr/share/fonts/X11/75dpi/:unscaled,";
$fontPath .= "/usr/share/fonts/X11/Type1,";
$fontPath .= "/usr/share/fonts/X11/100dpi,";
$fontPath .= "/usr/share/fonts/X11/75dpi,";
- For earlier versions of Ubuntu, see this link : VNCOverSSH Ubuntu Wiki
- Setup the server.
- Open a terminal and enter:
- The first time you run a server you will be asked a password:
ubuntu@ubuntu:~$ vncserver :1
You will require a password to access your desktops.
Password: #Enter your desired password here
Verify: #Confirm Password
New 'X' desktop is ubuntu:1
Starting applications specified in /etc/X11/Xsession
Log file is /home/ubuntu/.vnc/ubuntu:1.log
ubuntu@ubuntu:~$
This password is our only security so choose well
- Note: The name of your server is your hostname:1
- This creates a new directory in your home directory ~/.vnc
The vnc server will give access to your ubuntu server as the user who started the server.
- Your password is encrypted in ~/.vnc/passwd
- You can change your password with:
Code:
vncpasswd ~/.vnc/passwd
- The vncserver uses ~/.vnc/xstartup to start/configure your session. These are the start scripts I find most helpful :
- Gnome
##!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid navy # Choose your color
x-window-manager &
{
(gnome-panel 2> /dev/null &)
}
xterm &
- XFCE
##!/bin/sh
xrdb $HOME/.Xresources
xfwm4 2> /dev/null &
xfce4-panel 2> /dev/null &
xfce4-terminal &
- KDE
##!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid navy # Choose your color
x-terminal-emulator -geometry 80x24+10+1- -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &
kicker 2> /dev/null &
Of the 3, IMO, XFCE gives the best results
- Restart the server (to re-load the configuration/xstartup)
Code:
vncserver -kill :1
vncserver -geometry 800x600 -depth 24 :1
See man vncserver for additional options
4. Start the server (later if needed).
You will likely want to reduce the resolution as the java applet will run in a firefox window :
Code:
vncserver -geometry 800x600 -depth 24 :1
If you have a large monitor you may be able to increase the server resolution (-geometry 1280x1024).
Note: 1024x768 is nice (client resolution @ 1280x1024)
5. You can stop the server at any time with vncserver -kill
6. Note: Additional servers ~ You can start additional servers with other defaults, for example :
Code:
vncserver -geometry 1024x768 -depth 24 :2
THESE ADDITIONAL SERVERS WILL ALL USE THE SAME PASSWORD (unless you start them under an alternate user name).
Client setup
1. Enable the commercial repos as above.
2. Install by any means sun-java6-jre and sun-java-6-plugin
Code:
sudo apt-get install sun-java6-jre and sun-java-6-plugin
Note: You do not need a vnc (client) viewer for this how-to.
3. Allow java : In Firefox Edit -> Preferences Select the "Content" tab, tic off the "Load images automatically" "Enable JavaScript" and "Enable Java" boxes.
Connect
Open Firefox, in the address bar type <vnc_server_ip> : 5801
If needed, you can obtain the IP address of the server with a ping (see "Server" section above)
For example:
<name_of_dyndns_server>:5801
The java applet will start automatically.
If you use NoScript (or other java blockers) you will need to allow 192.168.1.25:5801 once the connection is established.
Click the connect button.
Note: If you reload the firefox window you will need to log in again.
Screen shots :

References :
VNC Ubuntu wiki
Bookmarks