X11, VNC, RDP
Sunday afternoon quest to replace a dead motherboard with remote access and a late 2013 Macbook
March 27, 2022
Dead motherboard after a humid day. Remote access to the rescue!
Local machine: Late ‘13 Macbook Pro, 8GB ram, Ubuntu 20.04, LXDM + Openbox, ~300mbps WiFi
Remote machine: AMD Ryzen 3900X, Nvidia GTX 2070s, 32GB ram, 1Gbit/s Internet
Networking
SSH port forwarding
ssh -L local_port:dst_host:dst_port remote
dst_host
and dst_port
are relative to remote.
→ TCP!
Wireguard
→ UDP! ✅
Generating key pairs
1 pair for each of local and remote. In all references below, “remote” is the with publicly accessible address which “local” connects to regardless of perspectives.
To generate keypair:
cd /etc/wireguard
umask 077
wg genkey > privatekey
wg pubkey > publickey < privatekey
Configuring
Mainly involved copy-pasta from wireguard.com
Local:
sudo apt-get update && sudo apt-get install wireguard wireguard-tools -y
At /etc/wireguard, create wg0.conf
. wg0
can be replaced with an arbitrary, valid interface name.
[Interface]
Address = 10.90.80.3/24
# Use content of `privatekey`
PrivateKey = R29kIHNhdmVzIHRoZSBxdWVlbgo=
[Peer]
# Use content of `publickey` from remote
PublicKey = VGhlIGZhc2Npc3QgcmVnaW1lCg==
Endpoint = accessible.ip-or-address:51820
AllowedIPs = 10.90.80.0/24
Remote:
yay -Syu wireguard-tools
[Interface]
Address = 10.90.80.2
# Use content of `privatekey` from remote
PrivateKey = QSBwb3RlbnRpYWwgSCBib21iCg==
ListenPort = 51820
# so changes made to wg interface is saved on shutdown
SaveConfig = true
[Peer]
# Use content of `privatekey` from local
PublicKey = VGhleSBtYWRlIHlvdSBhIG1vcm9uCg==
AllowedIPs = 10.90.80.0/24
Connecting
On both sides:
wg-quick up wg0 # or whatever interface name configured.
Remote Desktop
Approaches (in the order attempted):
XRDP
Remote: xrdp + xorgxrdp-nvidia
# awesome arch, package straight off xorgxrdp's `nvidia_hack` branch!
yay -Syu xrdp xorgxrdp-nvidia
# param=xrdp/xorg.conf → param=xrdp/xorg_nvidia.conf in /etc/xrdp/sesman.conf
sudo systemctl restart xrdp
Required a startwm.sh at home directory to start the usual desktop environment:
(~/startwm.sh)
#!/bin/bash
# adjust 1000 to current user id
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
/usr/bin/lxsession > ~/xrdp-lxsession.log 2>&1
Local: Remmina
sudo apt-get update && sudo apt-get install remmina -y
Add new connection → RDP → Address 10.90.80.2:3389
→ Save and connect
30fps-ish, started its own X11 session usable for coding. Some games would not start because there was no 3D acceleration; scrolling artifacts in browser; 2-3s delay at times… alternatives?
X11VNC
Screen grabber, tight encoding, compressed images, used existing LXDM session.
Remote:
yay -Syu x11vnc
# sudo because lxdm*auth needed root access
# -listen was a no-password way to limit access to the only wg peer
# :0 because existing lxdm session has been stopped
sudo x11vnc -listen 10.90.80.2 -display :0 -geometry 1920x1080 -auth /var/run/lxdm/lxdm-:0.auth -forever
Local:
Reminna → VNC → 10.90.80.2:5900
25fps-ish, 3D games ran, frames dropped occasionally, scrolling artifacts in browser, low constrast (24-bit bitdepth?)
TurboVNC
Included VirtualGL (from the same author, dcommander) integration. TightVNC replacement.
Remote:
yay -Syu turbovnc
# :0 because it starts by default at :1, causing misalignment between the DISPLAY (:1) env var and VGL_DISPLAY (set to :0 for reason not known to author)
# reused startwm.sh from xrdp attempt
vncserver :0 -vgl -wm ~/startwm.sh
# enter password for first time setup
Local:
Tried Remmina → Connection timed out. TurboVNC log said client was not RFB-capable…
sudo apt-get install turbovnc -y
→ No such package…
TurboVNC.org → Downloads → Sourceforge → latest stable of *_amd64.deb
# any of java runtime available in 20.04
sudo apt-get update && sudo apt-get install openjdk-17-jre -y
sudo dpkg -i turbovnc.deb
TurboVNC Viewer from app launcher → enter 10.90.80.3:5900
→ options → select lossless tight + zlib → Connect → enter password → Connected!
>30fps, smooth scrolling with no noticeable artifacts!
Videos was \< 20fps. bmon
showed ~64mbps upload traffic (limited by upload / wifi bandwidth?) → switched to Tight + perceutually-lossless JPEG + interframe comparison → videos back at ~25fps and image quality similar to lossless + zlib!
Occasional drop but sufficient for browsing + smooth Alt-Tabs + watching youtube videos