Remote desktop on ubuntu server with vnc

Creating Additional Desktops

New desktop environments are created using the vncserver utility. If vncserver is not already installed, it may be installed from a terminal window as follows:

sudo apt-get install vnc4server

Once the VNC server package is installed, the next step is to assign a password to protect the desktops. This can be achieved using the vncpasswd tool. Run this tool from the command-line prompt in a terminal window and enter the password of your choice.

The desktop we have used so far in this chapter is desktop :0. New desktops must be assigned different numbers. For example to launch desktop :1 run the following command from a terminal window command-line prompt:

vncserver :1

This will start a new desktop in the background ready for a remote user to connect to. To connect to the desktop follow the steps for connecting to desktop :0 outlined above but this time use port 5901 instead of port 5900 (you will similarly use port 5902 for desktop :2 and so on).

When the desktop appears you will notice that it doesn't look much like the standard desktop:

The problem here is that we need to configure the VNC session to launch the correct desktop. To do this shutdown the VNC desktop session as follows:

vncserver -kill :1

Next go to your home folder and edit the $HOME/.vnc/xstartup file. This will look similar to the following file:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

To configure this startup script to launch the standard desktop (known as the GNOME desktop) change the twm& line so that the file reads:

#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &

unset SESSION_MANAGER
sh /etc/X11/xinit/xinitrc

Restart the vncserver:

vncserver :1

Finally, reconnect from the remote system. The full desktop should now appear in the vncviewer or vinagre window.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

                                               
88 88 88
"" 88 88
88 88
88 ,adPPYb,88 8b d8 88,dPPYba,
88 a8" `Y88 `8b d8' 88P' "8a
88 8b 88 `8b d8' 88 88
88 "8a, ,d88 `8b,d8' 88 88
88 `"8bbdP"Y8 "8" 88 88

Enter the code depicted in ASCII art style.