Remote desktop setup on Ubuntu 15.04

35,140

You can use vnc for gui access to server.

Install the VNC-server

apt-get install vnc4server

Please make sure that you are using only vnc-server & no other VNC-server are installed as this could give errors in future mostly that clipboard sharing between the host Ubuntu Server & vnc-client machine. You can check it as follows:

xxx@yyy ~ $ sudo dpkg -l | grep vnc
ii  vnc4server                                            4.1.1+xorg4.3.0-37ubuntu5                           amd64        Virtual network computing server software
xxx@yyy ~ $

Please uninstall if tightvnc or anything similar installed. Adding VNC user

In my case I am using user=sssss it will differ in your case. You can use any username for the same.

adduser sssss

xxx@server1:~$ sudo adduser sssss
Adding user `sssss' ...
Adding new group `sssss' (1001) ...
Adding new group `sssss' (1001) ...
Adding new user `sssss' (1001) with group `sssss' ...
Creating home directory `/home/sssss' ...
Copying files from `/etc/skel' ...

Enter new UNIX password: <--yourpassword
Retype new UNIX password: <--yourpassword
passwd: password updated successfully
Changing the user information for sssss
Enter the new value, or press ENTER for the default
    Full Name []: <--ENTER
    Room Number []: <--ENTER 
    Work Phone []:<--ENTER 
    Home Phone []:<--ENTER
    Other []:<--ENTER 
Is the information correct? [Y/n]<--ENTER

Start the vncserver with the user, for this use:

su - srijan
vncserver

It will see:

sssss@server1:~$ vncserver

You will require a password to access your desktops.

Password:<--Put your VNC password 
Verify:<--Put your VNC password
Password too long - only the first 8 characters will be used
xauth:  file /home/sssss/.Xauthority does not exist

New 'server1:1 (sssss)' desktop is server1:1

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

sssss@server1:~$

Make backup of the original file & then make the configuration

cp ~/.vnc/xstartup ~/.vnc/xstartup.bak > ~/.vnc/xstartup
vi ~/.vnc/xstartup

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

Make the startup script for the vncserver

sudo vi /etc/init.d/vncserver


#!/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 ] && vncserver :${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 "vncserver -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 it executable:

chmod +x /etc/init.d/vncserver

Make the configuration file for the vncserver by creating file as follows:

mkdir -p /etc/vncserver
vi /etc/vncserver/vncservers.conf

Give the entries like this.

VNCSERVERS="1:sssss"
VNCSERVERARGS[1]="-geometry 1024x768"

Add it into boot startups:

update-rc.d vncserver defaults 99

xxx@server1:~$ sudo update-rc.d vncserver defaults 99
 Adding system startup for /etc/init.d/vncserver ...
   /etc/rc0.d/K99vncserver -> ../init.d/vncserver
   /etc/rc1.d/K99vncserver -> ../init.d/vncserver
   /etc/rc6.d/K99vncserver -> ../init.d/vncserver
   /etc/rc2.d/S99vncserver -> ../init.d/vncserver
   /etc/rc3.d/S99vncserver -> ../init.d/vncserver
   /etc/rc4.d/S99vncserver -> ../init.d/vncserver
   /etc/rc5.d/S99vncserver -> ../init.d/vncserver
xxx@server1:~$

Reboot the machine.

To access server you can user any vnc client app, list is here

Share:
35,140

Related videos on Youtube

Toren
Author by

Toren

Updated on September 18, 2022

Comments

  • Toren
    Toren over 1 year

    I installed Ubuntu 15.04 in Eucalyptus cloud environment .

    Now I'd like to setup remote desktop connection from Windows Laptop to linux (Ubuntu 15.04).

    What is a best solution for that ? I tried FreeNX ,but it seems has trusty repositories only.

    Can somebody post a link to Remote desktop procedure for 15.04 ? Thanks a lot

    • Maarten Klop
      Maarten Klop almost 9 years
    • Arronical
      Arronical almost 9 years
      The answers so far concentrate on VNC based solutions. You can't use Windows Remote Desktop to access this, so will have to install a VNC client on your Windows Laptop. This is probably the best solution, as configuring xrdp so you can use RDP can be a nightmare!
  • Arronical
    Arronical almost 9 years
    The OP has asked to connect from a Windows machine, isn't Remmina a Linux only app?
  • Arronical
    Arronical almost 9 years
    Nice thorough guide to setup. UltraVNC is another good windows client for remote by VNC.
  • Maarten Klop
    Maarten Klop almost 9 years
    Yes, remmina is configured as server. Window PC should then be able to remote desktop in as usual via rdp protocol.
  • Arronical
    Arronical almost 9 years
    Wow, I've never heard of it being used as a server, thought it was just client end. I can't see any instructions on the question you've linked, do you know of any other guides?
  • Toren
    Toren almost 9 years
    I do not have a Ubuntu graphical interface , how to configure Remmina as server via command line ?
  • Toren
    Toren almost 9 years
    I configured all this but still can't connect with vnc client . I opened 5800 port on firewall , anything else ?