x11vnc Copy-and-Paste…

To prevent typos and OS line break-type kerfuffles, I typically copy files instead of copy-pasting any files’ contents across VNC sessions.

Somehow, I came across wanting to just copy-paste a file via a VNC session, which used to work ye long ago… But it just was not happening…

Diving into the ‘net for answers, I came across autocutsel… Although some places stated to use xstartup files, as I was using x11vnc, this was not possible, so I simply ended up creating a services file (with a dependency on the x11vnc service):

  • assuming x11vnc had been installed as a service (refer here), install autocutsel:
    • apt install autocutsel
  • create the /etc/systemd/system/autocutsel.service service file:
    [Unit]
    Description=Start autocutsel at startup.
    After=multi-user.target display-manager.service
    Requires=x11vnc.service
    
    [Service]
    Type=simple
    User=lightdm
    Environment="DISPLAY=:0"
    ExecStart=/usr/bin/autocutsel -s PRIMARY
    ExecStop=killall autocutsel
    Restart=always
    RestartSec=3
    
    [Install]
    WantedBy=multi-user.target graphical.target
  • reload systemd configuration:
    • systemctl daemon-reload
  • enable x11vnc service:
    • systemctl enable autocutsel
  • reboot

The catch? Having to specify the $DISPLAY

But… Somehow, everything I tried for x11vnc was pretty much borked – mainly only one-way (from Linux x11vnc to Windows VNC client).

It then struck me that the VNC client has a part to play – some Windows-based VNC clients had the “enable bidirectional copy-and-paste” option on the client (assuming the VNC server supported this).

After some trial-and-error:

Windows Client License x11vnc Copy-Paste Works?
RealVNC Viewer Commercial (viewer is freeware) Bidirectional
TightVNC Viewer Opensource Bidirectional
RemoteRipple Opensource Bidirectional
UltraVNC Viewer Opensource Unidirectionl (x11vnc host > Windows client)
TigerVNC Viewer Opensource Unidirectionl (x11vnc host > Windows client)

There were some other sites stating to also “play around” with the -selection [ CLIPBOARD | PRIMARY ], but I started off with PRIMARY and since it worked for me, I did not try it without (i.e. CLIPBOARD by default)…

2026/08/01 Update: Using TightVNC has some issues with x11vnc on Ubuntu LTS 24.04 when using Virt-Manager – attempting to press the left CTRL+ALT to break mouse/keyboard control from a “captive” guest VM windows on the x11vnc desktop will fail…

In this case, the solution is to double tap the SCROLL LOCK (or SCRLK) key (i.e. press twice in quick succession), then press the left CTRL+ALT keys to release control from the active KVM guest window.

Leave a Reply