vnc remote desktop server working - theunissenlab/lab-documentation GitHub Wiki

1 Installing requirements

on the server:

sudo apt-get update sudo apt install xfce4 xfce4-goodies tightvncserver

once these are installed run:

vncserver

this will prompt you to set a password, this will be the future vnc password for this machine. It will say New 'X' desktop is <server>:<number> It should start a server on ":" this is usually 1 or 2.

2 Setting up vncserver

this next step will require changing some settings in vncserver so first we want to kill our running server

vncserver -kill :<vncnumber>

This stops the vnc server. now we will make a backup of the startup script so that if all else fails we can get back to square 1

mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Now we will make another, first open the startup script with vim (or some other editor)

vim ~/.vnc/xstartup

make the contents of the file:

#!/bin/bash
# Look 1: xfce4, basic blue look
xrdb $HOME/.Xresources
export XDG_CONFIG_DIRS=/etc/xdg
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

## Look 2: gnome, a bit more complex
#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
#gnome-panel &
#gnome-settings-daemon &
#metacity &
#nautilus &

There are two looks availabe, Look 1, a simple xfce look. Not resource hungry and optimized for remote connection. Look 2 is a gnome look, closer to the unity desktop that we have standard on the computers in lab, at the cost of more resources.

touch ~/.Xresources

this will create an empty file if the file does not exist. We now need to make sure we can execute the xstartup script. To do that run the following command

chmod +x ~/.vnc/xstartup

now you can start your server. Run the command

vncserver

After running this command it will tell you what number the server is being run on New 'X' desktop is <server>:<number>. The port that it is run on is 5900 + <vncnumber>

3 Connecting to the server

Now the vncserver is running on port 5900 + <vncnumber> which is usually 5901 or 5902 on your local machine. To access this from the outside world, you need to connect to vpn, then use a vncviewer to open the desktop. On mac, simply open finder, then press Cmd+K and type vnc://<server_ip>:<port_number> where <port_number> is 5900 + <vncnumber>

⚠️ **GitHub.com Fallback** ⚠️