This method uses the lightweight XFCE4 desktop.
- Install the vncserver and desktop:
sudo apt-get update
sudo apt-get install xfce4 xfce4-goodies tightvncserver - Run vncserver to set a password:
- vncserver
- Kill the session:
vncserver -kill :1 - Backup the config file:
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak - Create a startup file:
nano ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 & - Ensure that file can run:
sudo chmod +x ~/.vnc/xstartup - Create a VNC Service file:
sudo nano /etc/init.d/vncserver
Paste in the following replacing "user" with a non root user:
#!/bin/bash
# common
PATH="$PATH:/usr/bin/"
export USER="user"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /lib/lsb/init-functions
# start
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISP$
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
# stop
stop)
log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISP$
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
# restart
restart)
$0 stop
$0 start
;;
esac
exit 0 - Make it executable:
sudo chmod +x /etc/init.d/vncserver - Update file permissions and allow any user to start X Server:
chown -R philc. ~/.vnc && chmod +x ~/.vnc/xstartup
sed -i 's/allowed_users.*/allowed_users=anybody/g' /etc/X11/Xwrapper.config - Start the service:
sudo service vncserver start
chmod +x /etc/init.d/vncserver
service vncserver start - Try connecting
- Once its working, add service to auto start:
sudo update-rc.d vncserver defaults
Connecting to the service
To connect to it begin an SSH session then run VNC:- ssh -p [Destination Firewall port number e.g. 22] -N -L 5901:127.0.0.1:5901 [username]@[domain name/ip] -v
- Using Mac's Finder/Go to Server or a Windows equivalent like Real VNC Viewer
vnc://127.0.0.1:5901
No comments:
Post a Comment