Vnc4server

From miki
Jump to navigation Jump to search

Install

Install package vnc4server:

sudo apt install vnc4server

Configuration

Start at boot

We follow instruction on Ubuntu-fr.


First create file /etc/init.d/vnc4server:

  • Edit as necessary. In particular, replace all occurences of users vnc and vnc1 by user on your server.
  • If server already runs an X server, don't use :0 since it will not be available.
# /etc/init.d/vnc4server
#

# Enregistrement du log
touch /var/lock/vnc4server

# Gestion des paramètres de la commande vnc4server
case "$1" in
start)
echo "Starting script vnc4server "
# We start server with xrandr support
su vnc -c 'vnc4server -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768 :0'
su vnc1 -c 'vnc4server :1'
;;
stop)
echo "Stopping script vnc4server"
su vnc -c 'vnc4server -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768 -kill :0'
su vnc1 -c 'vnc4server -kill :1'
;;
*)
echo "Usage: /etc/init.d/vnc4server {start|stop}"
exit 1
;;
esac
  
exit 0
  • chmod and add to init:
sudo chmod 755 /etc/init.d/vnc4server
sudo update-rc.d vnc4server defaults
  • Start the server, this will create a password entry for each VNC desktop:
sudo /etc/init.d/vnc4server start

Edit VNC configuration for each user:

vi ~USER/.vnc/xstartup
  • On XUbuntu, the line for x-terminal-emulator was incorect. The correct line:
x-terminal-emulator --geometry=120x50+10+10 --title "$VNCDESKTOP Desktop" &

Connect

On the client, run:

xtightvncviewer my_vnc_server:1         # Or :0, :2...

Troubleshoot

  • On the server, see .log files in ~/.vnc.