Skip to content

vm broker setup vnc server (ubuntu)

Allan Roger Reid edited this page Dec 7, 2023 · 3 revisions

Setup VNC Server on ubuntu

Setup tools

sudo apt update
sudo apt install xfce4 xfce4-goodies -y
sudo apt install tigervnc-standalone-server -y

Run vncpasswd. Input a memorable password when prompted. Do not set a read-only password.

vncpasswd

Prepare systemd

cat << EOF > ~/.vnc/xstartup
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 
EOF
chmod u+x ~/.vnc/xstartup

Setup systemd. Add the following file

sudo vi /etc/systemd/system/[email protected]
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=ubuntu
PAMName=login
PIDFile=/home/%u/.vnc/%H%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :%i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver :%i -geometry 1440x900 -alwaysshared -fg -localhost no
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

Start systemd

sudo systemctl daemon-reload
sudo systemctl stop [email protected]
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
sudo systemctl status [email protected]

Connect

to hostname.domain:port where port was previously defined in the lxd node's streams definition e.g.

upstream perforce-bijan-vnc {
  server perforce-bijan.lxd:5901;
}

server {
  listen 20035;
  listen [::]:20035;
  proxy_pass perforce-bijan-vnc;
}
Clone this wiki locally