keepcalculator

06 Numbers and Powers

Enable Remote Desktop VNC on Kubuntu

Card No. 06·38874 · Updated · Standard formula, shown below

To enable remote desktop VNC on Kubuntu, you install a VNC server package, configure it to share the desktop, and connect from another device using a VNC client. The built-in KDE Remote Desktop (KRDC) client and the system settings panel provide the most straightforward path for most users.

What VNC Is and How It Works

VNC (Virtual Network Computing) is a graphical desktop sharing protocol that transmits the screen image and input events (keyboard and mouse) over a network. The server runs on the machine you want to control, and the client displays the remote desktop. VNC is platform-independent, so a Windows, macOS, or Linux client can connect to a Kubuntu server.

Kubuntu uses the KDE Plasma desktop, which includes a built-in VNC server module called KRDP (KDE Remote Desktop Protocol) or the older Krfb. The system settings app has a “Desktop Sharing” section that configures this server. Alternatively, you can install a standalone VNC server like TigerVNC or x11vnc for more control.

Prerequisites and Preparation

Before enabling VNC, ensure your Kubuntu system is up to date and you know the IP address of the machine. You will also need a VNC client on the device you are connecting from—on Kubuntu, KRDC is preinstalled; on other platforms, you can use RealVNC Viewer, TightVNC, or TigerVNC Viewer.

  • Update your system: sudo apt update && sudo apt upgrade
  • Find the IP address: ip a or check the network settings in the system tray.
  • Decide whether you need a persistent server (runs at boot) or on-demand sharing.

Method 1: Using KDE Desktop Sharing (GUI)

This is the simplest method for most users because it uses the built-in Plasma components.

  1. Open System Settings from the application launcher.
  2. Navigate to Network → Desktop Sharing.
  3. Check the box Allow remote connections to this computer.
  4. Choose a password for incoming connections. This is required for security.
  5. Select whether you want to allow uninvited connections (always available) or only when you click “Share” in the system tray.
  6. Click Apply.

The server will start immediately. To connect, use a VNC client and enter the target machine’s IP address and port (default is 5900). You will be prompted for the password you set.

Method 2: Installing TigerVNC Server (CLI)

If you prefer a command-line approach or need a server that starts automatically at boot, TigerVNC is a reliable choice.

  1. Install the package: sudo apt install tigervnc-standalone-server
  2. Set a VNC password for your user: vncpasswd
  3. Start the server for a virtual display: vncserver :1 -geometry 1920x1080 -depth 24
  4. Connect to IP:5901 (display :1 maps to port 5901).

To make it start at boot, add a systemd service or use the ~/.vnc/xstartup script to launch the Plasma desktop. A basic xstartup file looks like this:

#!/bin/sh
unset SESSION_MANAGER
exec startplasma-x11

Make it executable: chmod +x ~/.vnc/xstartup.

Method 3: x11vnc for the Current Physical Display

If you want to control the exact screen that is attached to the monitor (not a virtual display), x11vnc is the tool.

  1. Install it: sudo apt install x11vnc
  2. Set a password: x11vnc -storepasswd
  3. Start the server: x11vnc -forever -shared -rfbauth ~/.vnc/passwd

This method shares the physical display, so you will see the same screen as if you were sitting at the machine. It is useful for troubleshooting or when you need to interact with the actual session.

Configuring the Firewall and Network

Kubuntu’s default firewall (ufw) is usually inactive, but if you have enabled it, you must allow VNC traffic.

  • Allow the default VNC port: sudo ufw allow 5900/tcp
  • If using multiple displays, allow each port (5901, 5902, etc.).
  • If you are on a local network, ensure the router does not block the port. For remote access over the internet, you would need port forwarding, but that is not recommended without a VPN.

Common Problems and Troubleshooting

Many issues arise from simple configuration mistakes. Here are the most frequent ones:

  • Connection refused: The server is not running or the port is wrong. Check with ss -tulpn | grep 5900.
  • Blank screen: The xstartup script may not be launching the desktop correctly. Ensure it is executable and uses the correct session command.
  • Authentication failure: The password may be set for the wrong user, or the VNC server is using a different password file.
  • Slow performance: Reduce color depth (e.g., -depth 16) or use a faster compression method in the client.

Security Considerations

VNC is not encrypted by default, so any data transmitted (including your password) can be intercepted on an untrusted network. For internet use, always tunnel VNC through SSH or use a VPN. On a local home network, the risk is lower but still present.

To secure your VNC server:

  • Use a strong, unique password.
  • Limit connections to specific IP addresses using firewall rules.
  • Consider using SSH tunneling: ssh -L 5900:localhost:5900 user@host and then connect to localhost:5900.
  • Disable the server when not in use, especially on a laptop.

Alternatives to VNC

VNC is not the only remote desktop option for Kubuntu. Depending on your needs, you might prefer:

  • RDP (Remote Desktop Protocol): Use xrdp to connect from Windows’ built-in Remote Desktop client. It often performs better over low bandwidth.
  • Wayland native sharing: If you use Wayland (the default in recent Kubuntu), the built-in desktop sharing uses the PipeWire-based portal. VNC servers like x11vnc do not work with Wayland; you would need a Wayland-compatible server or switch to X11.
  • TeamViewer or AnyDesk: Third-party tools that handle NAT traversal and encryption automatically, but they are not open source and require an account.

Frequently Asked Questions

Does Kubuntu have a built-in VNC server?

Yes, Kubuntu includes the KDE Desktop Sharing module (based on Krfb), which acts as a VNC server. You can enable it from System Settings → Desktop Sharing. It is simple but limited in options compared to standalone servers.

How do I connect to Kubuntu from Windows?

Install a VNC client like RealVNC Viewer or TightVNC on Windows. Enter the Kubuntu machine’s IP address and port (default 5900), then provide the password you set in the server configuration.

Why is the VNC screen blank or frozen?

This usually happens when the VNC server starts a new session instead of attaching to the existing desktop, or when the xstartup script is misconfigured. For x11vnc, it attaches to the physical display, so this issue is less common. For TigerVNC, ensure the xstartup script correctly launches Plasma.

Can I use VNC over the internet?

Yes, but you must forward the VNC port on your router and ideally use an SSH tunnel or VPN for encryption. Without encryption, your session is vulnerable to eavesdropping. Services like TeamViewer are easier for internet use because they handle NAT and encryption automatically.

Does VNC work with Wayland?

Traditional VNC servers like x11vnc do not support Wayland because they rely on X11. Kubuntu 22.04 and later default to Wayland. You can either switch to an X11 session at login or use the built-in KDE remote desktop feature, which supports Wayland via the PipeWire portal.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →