Keli's Mumbo Jumbo

Small aim is a crime, have great aim.

0%

Vncserver Without X

The most light-weight setup, to have a long-running GUI application on Linux server, is to simply use a vncserver, then run the application after connected to the vncserver. This way you don't have to install many of the X11-related packages, and memory footprint is considerablly smaller.

Step 1: Install vncserver and a window manager of your choosing (I use icewm).

1
apt install xterm xfonts-base xfonts-scalable tightvncserver icewm sakura

Where sakura is a light-weight terminal emulator that I prefer.

Step 2: Create init files for vncserver session.

1
2
3
4
5
6
7
mkdir .vnc
cat > /.vnc/xstartup <<EOF
#!/bin/bash
xrdb \$HOME/.Xresources
exec /etc/X11/Xsession
EOF
chmod +x .vnc/xstartup

You could also create a vnc password by running vncpasswd.

Step 3: Run vncserver

1
vncserver :1 -depth 24 -geometry 1280x800 -localhost -interface lo -nolisten tcp

Vncserver will listen on localhost:5901, and you're pretty much done at the server side. You could also make it a systemd service instead:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
sudo tee /etc/systemd/system/vncserver@.service <<EOF
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=your_user
Group=your_group
WorkingDirectory=/home/your_user
PIDFile=/home/your_user/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :%i -depth 24 -geometry 1280x800 -localhost -interface lo -nolisten tcp
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable vncserver@1.service
systemctl start vncserver@1.service

To connect to the vncserver, you'll need to forward the vnc connection to localhost:5091 on the server side via a ssh tunnel:

1
ssh -L 5901:localhost:5901 -C -N server_ip

On Mac OS, I recommend Secure Pipes which is a great tool for managing multiple tunnels and keeping connections alive.

Now use any vnc client and connect to localhost:5901, you'll be connected to the vncserver. On Mac OS, simply launch Screen Sharing from spotlight, it's a fairly good vnc client.