September 10, 2024
I have two computers I use simultaneously: Windows 11, and Linux (Ubuntu, on X11 with dwm). I wanted to use both on the same big monitor, without needing to change inputs…could I use some kind of remote desktop from the Windows machine? The answer is yes - VNC. Here’s how you can do that.
VNC lets you use a desktop session remotely; for that, you need a VNC server. I decided to use TigerVNC, because it’s quite simple and allows sharing an existing desktop session.
On Ubuntu, that means:
sudo apt install tigervnc-standalone-server tigervnc-scraping-server
The second package, tigervnc-scraping-server
, provides x0vncserver
.
Normally, VNC creates a new virtual display (and desktop session) when you connect remotely.
However, I want to share the current display, as if I was using the Linux computer directly (except I won’t, only kinda, via the network).
That’s what x0vncserver
does, it lets you share and control the existing X server.
Next, create a password. Run:
mkdir -p ~/.config/tigervnc/passwd
vncpasswd ~/.config/tigervnc/passwd
Then enter a strong and complicated password (hi DT fans).
Your password will be obfuscated and stored in ~/.config/tigervnc/passwd
, and used to authenticate you when you connect remotely.
Once that’s done, run:
x0vncserver -localhost no -rfbauth ~/.config/tigervnc/passwd
Explanation:
-localhost no
: allow connections from outside of the machine-rfbauth $XDG_CONFIG_HOME/tigervnc/passwd
: authenticate users with the password you previously enteredThis will start a VNC server in the background, listening on port 5900 by default, which you can kill with x0vncserver -kill
.
Make sure nothing (like a firewall) is blocking that port.
For me, since I use VNC sparingly, turn it off after I’m finished, and I only use it on the local trusted network, this is enough. However, you can also secure your connection with an X.509 certificate (I might do this at a later point and update the post).
Install TigerVNC on your Windows machine.
Enter your Linux computer’s IP, followed by a colon and the port number (5900 if you kept the default), and click connect.
You’ll be asked to enter the password (the same one you typed into vncpasswd
), and then you’ll be connected.
You might notice some keyboard shortcuts don’t get sent to the remote computer. For that to work, you need to press F8 (potentially while holding down the Fn key), which will pop open a menu. In that menu, click “full screen”, and all your shortcuts will work now.