VNC

From Wildsong
Revision as of 20:54, 17 June 2023 by Brian Wilson (talk | contribs) (Created page with "== Ubuntu Server == To allow access to a headless Ubuntu Server, install vncserver; note this is the version "tightvncserver". Not "real" not "ultra" not "tiger"... sudo apt install tightvncserver fvwm xterm Set it to start at boot, create the file /etc/systemd/system/[email protected] <pre> [Unit] Description=Start a VNC Session at startup With Desktop ID 1 After=multi-user.target network.target [Unit] Description=Start a VNC Session at startup With Desktop ID 1...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Ubuntu Server

To allow access to a headless Ubuntu Server, install vncserver; note this is the version "tightvncserver". Not "real" not "ultra" not "tiger"...

sudo apt install tightvncserver fvwm xterm

Set it to start at boot, create the file /etc/systemd/system/[email protected]

[Unit]
Description=Start a VNC Session at startup With Desktop ID 1
After=multi-user.target network.target
[Unit]
Description=Start a VNC Session at startup With Desktop ID 1
After=multi-user.target network.target

[Service]
Type=forking
# IMPORTANT!!! Change 'username' to actual user that connect to the session
User=YOURLOGINNAMEHERE
ExecStartPre=/bin/sh -c '/usr/bin/tightvncserver -kill :%i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/tightvncserver :%i -geometry 2048x1024 -depth 24
ExecStop=/usr/bin/tightvncserver -kill :%i

[Install]
WantedBy=multi-user.target

Set it to start,

systemctl enable [email protected]

For good measure, reboot. You should see the service is running. For example,

(base) bwilson@bellman:/etc/systemd/system$ systemctl status [email protected][email protected] - Start a VNC Session at startup With Desktop ID 1
     Loaded: loaded (/etc/systemd/system/[email protected]; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2023-06-17 11:49:30 PDT; 6min ago
    Process: 13467 ExecStartPre=/bin/sh -c /usr/bin/tightvncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=>
    Process: 13472 ExecStart=/usr/bin/tightvncserver :1 -geometry 2048x1024 -depth 24 (code=exited, status=0/SUCCESS)
      Tasks: 9 (limit: 38023)
     Memory: 49.0M
        CPU: 2.100s
     CGroup: /system.slice/system-vncserver.slice/[email protected]
             ├─13483 Xtightvnc :1 -desktop X -auth /home/bwilson/.Xauthority -geometry 2048x1024 -depth 24 -rfbwait 120>
             ├─13493 xterm -geometry 80x24+10+10 -ls -title "X Desktop"
             ├─13494 /usr/bin/fvwm
             ├─13500 /usr/lib/fvwm/2.6.8/FvwmButtons 9 4 none 0 8 RightPanel
             ├─13501 /usr/lib/fvwm/2.6.8/FvwmEvent 11 4 none 0 8 EventNewDesk
             ├─13502 /usr/lib/fvwm/2.6.8/FvwmPager 13 4 none 0 8 "*"
             ├─13503 /usr/lib/fvwm/2.6.8/FvwmIconMan 15 4 none 0 8
             ├─13504 /usr/lib/fvwm/2.6.8/FvwmScript 17 4 none 0 8 FvwmScript-DateTime
             └─13506 -bash

Create an xstartup file in ~/.vnc, it starts a window manager and an xterm.

#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
/opt/fvwm/bin/fvwm2 &

Windows 10 (and probably Windows 11)

Install tightvnc from the MSI package.

When installing, no need to associate .vnc files with viewer; uncheck that. Under the service configuration section, check to register as a system service. Uncheck allowing Ctl-Alt-Del. Set up passwords when prompted, one for regular and one for admin.

On another computer, I tested the viewer. I can connect to bellman locally at 192.168.123.2:5901 and see the virtual FVWM desktop with its open xterm.

Reflector

This is the whole point of this exercise: to run a reflector on a machine outside my network, so that I can get remote access to desktops that are behind a NAT firewall.

I downloaded and built vncreflector 1.2.4 from the tar file on the VPS running Debian 11. (It's easy to build compared to xvncserver!!) It is installed at /usr/local/sbin and I have a script to start it in /usr/local/sbin/start_vncreflector.sh that has the options in it.

Connect server to reflector

For the Ubuntu server, read "man tightvncserver", and find nothing of use. :-( Except a mention of vncconnect. Let's try that. I don't know what to use for the display option, this does not work. I am not authorized. This worked. It ran anyway, ha. Get the display name with xauth.

xauth list
vncconnect -display bellman:1 tarra.tarra.link:5599

For the Windows server,

Connect viewers to reflector

Use port 5999 on the reflector, and have your password ready. The one you entered when you set up the reflector config.