For the complete documentation index, see llms.txt. This page is also available as Markdown.

9.6 Remote Desktop

Remote desktop access technology allows one device to remotely control the desktop environment of another device over a network. Remote desktop protocols are mainly divided into two categories: framebuffer-based protocols (such as VNC, defined in RFC 6143) and instruction stream-based protocols (such as RDP, extended from the ITU-T T.120 protocol family (including T.128, i.e., T.share)). This section covers the configuration of both protocols on FreeBSD.

Directory Structure

/
├── home
   └── ykla
       └── .vnc
           ├── passwd              # VNC password file
           ├── xstartup             # VNC startup script
           └── config               # VNC configuration file
       └── .Xauthority              # X authorization file
├── usr
   └── local
       └── etc
           └── xrdp
               ├── xrdp.ini        # XRDP main configuration file
               ├── sesman.ini      # XRDP session manager configuration
               └── startwm.sh      # XRDP desktop environment startup script
└── var
    ├── run
       ├── sddm                     # SDDM authorization file directory
       ├── lightdm                  # LightDM authorization file directory
       └── user
           └── 120
               └── gdm              # GDM authorization file directory
    └── lib
        └── gdm                      # GDM legacy authorization file directory

x11vnc (FreeBSD as the Controlled End, Screen Mirroring)

x11vnc provides screen mirroring functionality. User operations are synchronously displayed on the physical monitor, and operations on the physical monitor are also visible in the VNC client. It is recommended to use it with SSH tunneling or SSL encryption to prevent VNC traffic from being sniffed.

If there is no physical monitor, x11vnc cannot be used, but an HDMI graphics dummy plug can be used instead of a physical monitor.

Installing x11vnc

  • Install using pkg:

  • Or install using Ports:

Creating a Password

Set the x11vnc access password:

Starting the Server (KDE 6 SDDM)

  • Start x11vnc using the specified password file and SDDM authorization file:

Warning

Since x11vnc does not yet support Wayland, if you select Wayland in the bottom-left corner of SDDM, you will not be able to enter the desktop.

  • Start x11vnc using the specified password file and LightDM authorization file:

  • Start x11vnc using the specified password file and GDM authorization file:

SDDM X11VNC

References

TigerVNC (FreeBSD as the Controlled End)

Enable the VNC server (only TigerVNC remains in Ports).

Installing TigerVNC Server

Install using pkg:

Or install using Ports:

Setup

Create the ~/.vnc/ path:

Edit the ~/.vnc/xstartup file and add the following lines:

Remove the # comment at the beginning of the line for the desktop session you want to enable.

Warning

Make sure to keep the & character.

Set the xstartup script to executable permissions:

  • Execute the command in the terminal to start the VNC server:

Start the VNC server on display :1:

Here :1 means DISPLAY=:1, i.e., the desktop display number is specified as 1, corresponding to VNC service port 5901. Desktop display numbers start from 0, but the port for number 0 is already occupied by the current desktop (unless it is a mirror VNC), so in practice the VNC service starts from 5901. You must specify port 5901 when connecting.

Test:

If no communication port is specified when starting the service, the system will automatically assign one.

Display the current user's process list:

To stop the service, use the command vncserver -kill :1; you must specify the port number.

  • If a firewall is enabled, using IPFW as an example, enter the following command in the terminal:

The above command opens ports 5900-5910, i.e., DISPLAY 0-10. Execute ipfw list to view all current firewall rules and confirm they have taken effect.

References

XRDP (FreeBSD as the Controlled End)

Installing XRDP (Based on KDE6)

Install using pkg:

Or install using Ports:

View configuration files:

Configuring XRDP

Configure the daemons:

Edit the /usr/local/etc/xrdp/startwm.sh file, find #### start desktop environment, and modify as follows:

Restart the system for changes to take effect.

Configuring Chinese Environment (User Using Default sh)

Edit the /usr/local/etc/xrdp/startwm.sh file, add or modify the following content to set environment variables:

Set the system language to Chinese.

Troubleshooting and Unresolved Issues

No Sound Under XRDP

This issue can be mitigated through the Firefox browser.

Remotely Accessing FreeBSD via TigerVNC from Windows

Download the TigerVNC viewer:

Check the VNC port on FreeBSD:

Troubleshooting and Unresolved Issues

Unable to Connect Due to Active Refusal by the Target Server

When using non-mirrored VNC connections, you must specify the port; otherwise, port 5900 is used by default. Since the service port for non-mirrored VNC is not 5900, the connection is refused.

SDDM VNC

Example:

SDDM VNC

No Audio Output When Remotely Accessing FreeBSD via VNC

This issue has not been resolved in this section.

Remotely Accessing FreeBSD via Windows Built-in Remote Desktop Connection (RDP)

xrdp FreeBSD

When logging into the device for the first time, there will be a security prompt. Enter yes, and after pressing Enter, the remote desktop window will pop up.

xrdp FreeBSD
xrdp FreeBSD
xrdp FreeBSD
xrdp FreeBSD

Troubleshooting and Unresolved Issues

If the Windows Remote Desktop Window Is Neither in the Top-left Corner Nor Full-screen, the Display Will Be Blurry

You should uncheck "Smart resizing".

Smart resizing

Using Android to Remotely Access FreeBSD via XRDP

Download the required software:

The mobile RDP software developed by Microsoft: Remote Desktop

This software supports RDP connections on the Android platform.

Change the top-left mouse operation to touch operation. The default mouse operation is not convenient enough; you can also choose to connect a mouse and keyboard via OTG for control.

Remote Desktop FreeBSD

Connection diagram (Chromium is being compiled in the background, so resource usage will be high):

Remote Desktop FreeBSD

Remotely Accessing Windows from FreeBSD via XRDP

freerdp3

Install using pkg:

Or using Ports:

Use FreeBSD to remotely connect to Windows 11 24H2 via freerdp3:

Warning

Passing the password directly via the /p parameter on the command line causes the password to appear in the process list (viewable via commands such as ps), which poses a security risk.

The 192.168.31.213 and ykla in the above example are placeholders and must be replaced with actual values. If the /p parameter is omitted in the example, the program will interactively prompt for the password after execution, which is more secure than writing the password in plaintext on the command line.

xfreerdp3 /u:ykla /p:z /v:192.168.31.213 parameter descriptions:

Parameter
Meaning
Description

xfreerdp3

Command

Note the x prefix

/u:ykla

Username

ykla is the Windows login name

/p:z

Password

z is the login password for Windows user ykla

/v:192.168.31.213

Server

Replace with the actual Windows host address

freerdp

References

Troubleshooting and Unresolved Issues

During testing, it was found that a connection was successfully established without entering a username, which may be related to the FreeBSD username being the same as the Windows username.

rdesktop (Does Not Support NLA)

net/xrdesktop2 is a graphical frontend for rdesktop. During testing, it became unresponsive when opening keyboard settings.


Install rdesktop using pkg:

Or install using Ports:

rdesktop has no frontend GUI; you need to enter commands in the terminal:

If you have not manually changed the Windows configuration, there is no need to add :port_number.

On the tested Windows 11 24H2, an error will be reported:

According to rdesktop team. CredSSP does not work[EB/OL]. [2026-04-04]. https://github.com/rdesktop/rdesktop/issues/71. This is a long-standing issue.

Danger

Disabling Network Level Authentication (NLA) exposes the RDP service to severe security threats, including but not limited to:

  • Credential forwarding attacks: After NLA is disabled, user credentials will be sent to the remote host and stored in its memory. Attackers can use techniques such as pass-the-hash to steal credentials and continue impersonating the user even after the session is disconnected.

  • Brute force attacks: Without pre-session authentication, attackers can attempt logins without restriction.

  • Denial of service attacks: The server allocates session resources for each connection without verifying identity.

It is strongly recommended to prioritize using freerdp3 (see above), which supports NLA/CredSSP, rather than disabling NLA. If you must disable NLA, please re-enable it immediately after the operation is completed, and ensure that the RDP port is not directly exposed to the public internet.

Steps to disable NLA are as follows, to be executed on the Windows machine you want to remotely connect to:

Test the connection again:

rdesktop
rdesktop

Troubleshooting and Unresolved Issues

No Sound During Video Playback

Not yet resolved.

References

AnyDesk

AnyDesk can be used for remote access. FreeBSD supports amd64 and i386 architectures:

Due to copyright reasons (proprietary software may not be distributed without permission), users must build and install it themselves using Ports:

Since you need to accept the license agreement to use it, the BATCH=yes parameter cannot be used:

anydesk

View the post-installation notes for AnyDesk:

It indicates that the proc filesystem needs to be mounted. Testing has shown that the program cannot start properly without this filesystem mounted.

The root user cannot run AnyDesk; it must be run as a regular user:

The AnyDesk main interface that pops up after executing the command:

AnyDesk main interface

The party being connected must "Accept" to continue the connection.

Windows Remotely Accessing FreeBSD via AnyDesk

Windows remotely accessing FreeBSD via AnyDesk

FreeBSD Remotely Accessing Windows via AnyDesk

FreeBSD remotely accessing Windows via AnyDesk

Troubleshooting and Unresolved Issues

Unable to Move the Mouse in Windows When Remotely Connecting from FreeBSD via AnyDesk

To be resolved.

RustDesk Relay Server

Note

This is a relay ID server and cannot be remotely controlled itself.

RustDesk cannot be used to control FreeBSD.

  • Install using pkg:

Or install using Ports:

Configuring the RustDesk relay server:

Create a dedicated user to run the RustDesk relay service, avoiding running as root:

  • Start hbbs:

  • Then start hbbr:

Open the RustDesk client on other devices. Both sides need to fill in the same "ID server (FreeBSD IP address or domain name)" and "Key", leaving other fields blank. Enter the ID displayed on the controlled end on the controlling end to connect.

References

  • FreshPorts. rustdesk-server Self hosted RustDesk server[EB/OL]. [2026-03-25]. https://www.freshports.org/net/rustdesk-server/. FreshPorts provides RustDesk relay server port details and installation guide.

  • Safe Rabbit. Remote control software RustDesk self-hosted server full-platform deployment and usage tutorial[EB/OL]. (2024-02-20)[2026-03-25]. https://www.cnblogs.com/safe-rabbit/p/18020812. Blog providing a detailed full-platform deployment and usage tutorial for RustDesk self-hosted relay server.

Exercises

  1. Port more VNC servers to Ports.

  2. Adapt for Wayland.

  3. The diversity of remote desktop protocols (RDP, VNC, SPICE, X11 Forwarding) reflects different abstraction levels of the graphics stack. Compare the design trade-offs of each protocol in terms of bandwidth efficiency, security, and session persistence, and analyze the technical constraints of FreeBSD as a remote desktop server in protocol selection.

Last updated