How to use Barrier on Linux to share keyboard and mouse between multiple computers

Introduction to Barrier

Barrier is an open-source tool that allows sharing a single keyboard and mouse between multiple computers, functioning as a virtual KVM. Originally known as Synergy, Barrier has evolved to offer a more stable and cross-platform experience, including excellent support for Linux. In this post we will see how to install it, configure it, and get the most out of it in a work environment with multiple Linux stations, improving productivity and reducing peripheral clutter.

What is Barrier

Barrier acts as a server and one or more clients that connect over the network. The machine that has the keyboard and mouse physically attached functions as the server, while the other machines act as clients and receive input from the server when the cursor crosses the edge of the screen. This architecture allows control to flow naturally, as if all monitors belonged to a single extended desktop. Additionally, Barrier supports shared clipboard, making it easy to copy and paste text or images between machines without needing external services.

Prerequisites

Before installing Barrier, it is necessary to ensure that all machines have a stable network connection, preferably via Ethernet cable to minimize latency. Additionally, each machine should run a recent Linux distribution with access to official repositories or Snap/Flatpak packages. It is recommended to enable the firewall to allow traffic on TCP port 24800, which is the default port that Barrier uses for communication between server and clients. Finally, it is useful to have installed a desktop environment that supports X11 or Wayland, as Barrier relies on the input extensions of these systems.

Installation on Major Distributions

Installing Barrier on Linux is straightforward thanks to its presence in the repositories of most distributions. On Ubuntu and Debian, simply run sudo apt update and then sudo apt install barrier. On Fedora, the command is sudo dnf install barrier, while on Arch Linux use sudo pacman -S barrier. For those who prefer universal packages, Snap offers sudo snap install barrier and Flatpak provides flatpak install flathub org.barrier.Barrier. After installation, verify the version with barrier –version and ensure the executable is in your PATH.

Server Configuration

To configure the server, open the barrier application from the applications menu or run barrier & in a terminal. A window with a grid representing the monitors will appear. Drag and drop the icons to position them according to your physical layout; for example, if you have a monitor to the right of the server, move the client icon to the right of the central box. Define a name for the server (default uses the hostname) and choose the authentication method: none, password, or TLS. Click Apply and the server will start listening on TCP port 24800.

Client Configuration

On each client, start barrier and choose Client. In Server IP, enter the server’s IP address; if they are on the same subnet, you can use the hostname via mDNS or /etc/hosts. Ensure the authentication method matches that of the server (same password or TLS). Save the settings, press Start, and the client will connect; then the cursor will move seamlessly from the server’s screen to the client’s screen when touching the corresponding edge.

Daily Use and Tips

Once the connection is established, working with Barrier feels like using a single extended desktop: you can drag windows between monitors, copy text with Ctrl+V and paste it on another machine with Ctrl+V, and the shared clipboard will take care of the rest. You can also assign keyboard shortcuts to quickly switch focus between screens using barrierctl or the tray icon. To pause sharing, click the barrier icon and select Disable. Advanced users can create profiles that load automatically based on the detected network, ideal for laptops that switch between office and home.

Troubleshooting Common Issues

If the client fails to connect, verify that port 24800 is open in the server’s firewall (sudo ufw allow 24800/tcp on Ubuntu). Confirm there are no duplicate IPs and that the server is listening with sudo netstat -tlnp | grep barrier. If the cursor gets stuck at the edge, check that the monitor layout in the barrier interface exactly matches your physical positioning; even a one-pixel difference can block passage. Finally, if you notice lag, use a wired connection and prioritize barrier traffic on the router via QoS.

Conclusion

Barrier presents itself as a lightweight, free, and cross-platform solution that turns multiple machines into a single cohesive work environment. Its simple configuration on Linux, together with features like shared clipboard and optional authentication, makes it an attractive alternative to commercial KVM solutions. By adopting Barrier in your daily workflow, you will reduce peripheral clutter, gain flexibility, and improve productivity without needing additional hardware. We invite you to try it and share your experience in the comments so the community can continue growing. Moreover, its open-source code allows customization to suit the specific needs of each environment.

This post is also available in ESPAÑOL.

Leave a Reply

Your email address will not be published. Required fields are marked *

Esta obra está bajo una Licencia Creative Commons Atribución 4.0 Internacional para Francesc Roig francesc@vivaldi.net .