Before we start, this method works by sending whatever on the display to a VNC client, so it can’t handle multiuser login. Yet it’s an open-source solution and works great on a headless server.
I strongly recommend using a desktop environment or window manager that has no animation effects. Animation is just too bandwidth consuming. I’m using
lightdm as display manager and
i3 as window manager. No desktop environment present.
Assuming you have done setting up your graphics. Now install
# pacman -S tigervnc
If you are using Debian or Ubuntu,
# apt install tigervnc-standalone-server tigervnc-scraping-server
In general, install the packages that provide executable
Configuration & Run
~/.vnc/passwd for client authentication:
x0vncserver from your desktop session (for correct display number and X authentication):
$ x0vncserver -rfbauth=~/.vnc/passwd -NeverShared -PollingCycle=75
Try to connect to server’s 5900 port with your VNC client, the connection should be successful.
Ctrl+C to terminate the
x0vncserver you just run. Now get the display number of your desktop by querying the
DISPLAY environment variable of your desktop session:
$ echo $DISPLAY :2
Now you should be able to run
x0vncserver from any terminal (SSH, etc):
$ x0vncserver -Display=:2 -rfbauth=~/.vnc/passwd -NeverShared -PollingCycle=75
You may have found that if no monitor is connected to the server, the resolution of X server would be something like 1024×768 or 720×574, so would the VNC session. The solution is to use
xrandr to change the frame buffer resolution right after
Xorg launches. My
Xorg is launched by
lightdm, so firstly modify the
session-setup-script parameter in the
#!/bin/bash xrandr --fb WWWWxHHH
Change WWWWxHHH to the resolution you want. Then add executable permission to
# chmod +x /etc/lightdm/sessionsetup.sh
No protocol specified?
I’ve received “No protocol specified” error message which prevented me from launching
x0vncserver. This might be related to an X server authentication problem. Running
x0vncserver from desktop session should solve it.