bugged.be

"Think outside the [B0X]"
Icon

Install tight vnc server

1a. Install desktop environment and vnc server

sudo apt install xfce4 xfce4-goodies tightvncserver

1b. start the server

vncserver

Set passwords for user and view only user.

2. Configure the server
2a. exit the server

vncserver -kill :1

2b. Backup original xstartup file

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

2c. Create new xstartup

nano ~/.vnc/xstartup

with following content:

#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &

2d. Make it executable

sudo chmod +x ~/.vnc/xstartup

2e. Start the server

vncserver

3. Connect to vnc server
3a. Create a secure connection from desktop to server
Run on desktop:

ssh -L 5901:127.0.0.1:5901 -N -f -l

3b. Use vnc client and connect to:

localhost:5901

4. Run vnc server on boot
4a. Create the user vnc should run with.

sudo adduser

4b. Copy vnc server configuration to this user

sudo cp /root/.vnc/*.* /home//.vnc/.

4c. Change files owner

sudo chown *
# normally the user group is the same as the user name.
sudo chgrp *

4d. Create a startup file.

#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Required-Stop: networking
# Default-Start: S
# Default-Stop: 0 6
### END INIT INFO</code>

PATH="$PATH:/usr/X11R6/bin/"

# The Username:Group that will run VNC
export USER="new username"
#${RUNAS}

# The display that VNC will use
DISPLAY="1"

# Color depth (between 8 and 32)
DEPTH="16"

# The Desktop geometry to use.
#GEOMETRY="x"
#GEOMETRY="800x600"
#GEOMETRY="1024x768"
GEOMETRY="1280x1024"

# The name that the VNC Desktop will have.
NAME="new-vnc-server"

OPTIONS="-name ${NAME} -depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}"

. /lib/lsb/init-functions

case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;

restart)
$0 stop
$0 start
;;
esac

exit 0

5 Restart the server …
Check if the server is running:

ps -ef | grep vnc

If not running, check the logs with:

systemctl status vncserver.service

Category: Linux, vnc

Tagged: