Ubuntu Remote Desktop – multiple users
Anthony Gee | Feb 24, 2013 | Comments 3
When I got my new dedicated server setup with Ubuntu server 12.04 LTS, I wanted to use it both for website hosting and multiple users remote desktop work.
It took me some time to arrange all the steps to have the above completed, and as far as the hosting part was pretty easy, the multiple Ubuntu users desktop setup needed some jugs of coffee before start working as I wanted it.
So, I presume you have logged in to your server with some user already, so we will stat with updating the system:
|
1 |
sudo apt-get update |
Next, as I want all Gnome desktop features, will install it completely with:
|
1 |
sudo apt-get install ubuntu-desktop |
Unity looks fancy, but I want the old Gnome panel, and I do not need “compiz”, so:
|
1 2 3 |
sudo apt-get remove compix unity sudo apt-get install gnome-panel |
Next what we need is a VNC server.
|
1 |
sudo apt-get install vnc4server |
The tricky part here is that you have to create several configuration files for the Ubuntu Remote Desktop user. This is really time consuming if you have to read all the settings and creating the files by yourself.
It is more easy to start the VNC server which will create the files automatically:
|
1 |
vnc4server :2 |
You will be asked for a password so enter it, and then kill the server as we have to make some configuration changes:
|
1 |
vnc4server -kill :2 |
Edit the xstartup configuration file:
|
1 |
vi .vnc/xstartup |
And make it looks like this:
|
1 2 3 4 5 6 7 8 9 |
#!/bin/sh [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & x-window-manager & gnome-panel & gnome-session & |
Now you can start the vnc server with this:
|
1 |
vnc4server :2 -geometry 1024x768 -depth 24 |
Certainly you can change the settings if you want different Remote Desktop geometry.
Now use your preferred VNC client – http://remmina.sourceforge.net/ (Linux) and http://www.tightvnc.com/download.php (Windows) are my suggestions – and connect to the Ubuntu Remote Desktop server using x.x.x.x:2 as (:2) is the number of display used to run for the client. If you have more than one running you should use different number at the end.
As I saying different desktops, I am going to add another user to my Ubuntu Remote Desktop server.
For this I will need to repeat the above steps for creating (and starting) the VNC profile for each user. This one is not yet automatically implemented, but it is not a big deal.
First I will add another user:
|
1 |
sudo adduser newuser |
Complete the several steps for creating the user which is including creating the password and user personal information.
(A little trick when you want to add user with administrative privileges is to type the command as : adduser
)
Then start the VNC server once to create the VNC password:
|
1 2 |
sudo su newuser vnc4server :3 sudo su newuser vnc4server -kill :3 |
Open VNC startup file for the ‘newuser’
|
1 |
sudo vi /home/newuser/.vnc/xstartup |
And paste the same configuration as for the first user:
|
1 2 3 4 5 6 7 8 9 |
#!/bin/sh [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & x-window-manager & gnome-panel & gnome-session & |
Save the file and start the service
|
1 |
sudo su newuser vnc4server :3 -geometry 1024x768 -depth 24 |
Now using VNC client you can connect to the new user Desktop as going to x.x.x.x:3 address.
The next step is to automate a little bit the start-up precess for these Ubuntu Remote Desktop users. Otherwise you have to start vnc4server for each user when the server is rebooted.
So, switch to root (it is just more easier) and then create vncserver folder and create file as vncservers.conf:
|
1 2 3 |
sudo su - mkdir -p /etc/vncserver vi /etc/vncserver/vncservers.conf |
Inside put the following massive:
|
1 2 3 |
VNCSERVERS="2:user 3:newuser" VNCSERVERARGS[2]="-geometry 1024x768 -depth 24" VNCSERVERARGS[3]="-geometry 1024x768 -depth 24" |
Where ‘user’ is the main user you are dealing with (the one we configured VNC for initially) and ‘newuser’ which is the second user are we have created. If you have more users created and the above steps for settings passwords and vnc4srver start-up completed, add more lines accordingly wit (:4),(:5) etc. screens.
Then create startup script for VNC server as:
|
1 |
vi /etc/init.d/vncserver |
And put the following lines inside:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
#!/bin/bash unset VNCSERVERARGS VNCSERVERS="" [ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf prog=$"VNC server" start() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Starting $prog: " ulimit -S -c 0 >/dev/null 2>&1 RETVAL=0 for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV DISP="${display%%:*}" export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}" su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vnc4server :${DISP} ${VNCUSERARGS}" fi done } stop() { . /lib/lsb/init-functions REQ_USER=$2 echo -n $"Shutting down VNCServer: " for display in ${VNCSERVERS} do export USER="${display##*:}" if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then echo -n "${display} " unset BASH_ENV ENV export USER="${display##*:}" su ${USER} -c "vnc4server -kill :${display%%:*}" >/dev/null 2>&1 fi done echo -e "\n" echo "VNCServer Stopped" } case "$1" in start) start $@ ;; stop) stop $@ ;; restart|reload) stop $@ sleep 3 start $@ ;; condrestart) if [ -f /var/lock/subsys/vncserver ]; then stop $@ sleep 3 start $@ fi ;; status) status Xvnc ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" exit 1 esac |
Make the script executable, and add it to the startup scripts:
|
1 2 3 |
chmod +x /etc/init.d/vncserver update-rc.d vncserver defaults 99 |
Now:
|
1 2 |
service vncserver stop service vncserver start |
And all added users in /etc/vncserver/vncservers.conf will be able to connect via Remote Desktop.
Certainly make sure VNC ports are anebled on the firewall.
Also take in mind that VNC is alsways better to be combined with SSH tunnel as its encryption and vulnerability issues are well known.
Tags
Filed Under: Debian • Desktop • Operating Systems • Server Administration Utilities • Server Management • Tutorials • Web-hosting
About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the Onlinehowto.net website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.
This is interest article
Thanks
Thank You for sharing this tutorial, very good help.
Good article, but be aware there are several misplaced characters in the script, like “|>” in strange places.
Cheers.