1. Home
  2. Linux
  3. Share mouse and keyboard over lan on linux

How to share mouse and keyboard over the LAN on Linux

Barrier lets Linux users share both the mouse and keyboard over the local area network, effectively making it possible to control the input of one computer with another. It’s based on the code base of the tool Synergy. Here’s how to get it working on your system.

Installing Barrier

The Barrier application is readily available for installation on all Linux distributions through the Ubuntu Snap Store, as a Flatpak on Flathub, and via source-code. Also, the app is on the AUR for those that use Arch Linux.

Getting the Barrier program working on Linux is quite easy. To start the process, open up a terminal window on the desktop by pressing Ctrl + Alt + T or Ctrl + Shift + T on the keyboard. After that, follow the command-line installation instructions below to get everything working.

Arch Linux

On Arch Linux, Barrier is available as a custom AUR package. To start the installation, use the Pacman tool to get the “Git” and “Base-devel” packages set up on the system. These packages are required to interact with the AUR.

sudo pacman -S git base-devel

When the two packages are installed on your Arch Linux system, it is time to use the git clone command to download the Trizen AUR helper tool. With Trizen, installing Barrier is automatic, and you will not need to deal with dependency issues.

git clone https://aur.archlinux.org/trizen.git

Once you’ve downloaded the Trizen AUR helper, use the commands below to install it on the system.

cd trizen
makepkg -sri

Finally, install the Barrier application on your Arch Linux PC with:

trizen -S barrier

Snap package

There’s a Snap package release of Barrier. So, if you use a Linux PC that has access to Snap packages, getting the app working is incredibly simple. To start the process, ensure that you have the Snapd runtime running in the background. If not, follow this guide on Snapd to get it working.

Once you’ve gotten the Snapd runtime up and running on your Linux PC, it is time to install Barrier. Using the snap install command below, install the app!

sudo snap install barrier

Flatpak

If Snap packages aren’t your style, you’ll be happy to know that Barrier is also available in the Flathub app store as a Flatpak. To get the app working, start by ensuring that the latest Flatpak runtime is installed.

Once you’ve gotten the Flatpak runtime working on your Linux PC, use the commands below to get the latest release of Barrier up and running.

flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

flatpak install flathub com.github.debauchee.barrier

Source-code

While we do not recommend it, it is possible to compile the source code for Barrier on Linux and run it. Click here to get your hands on it.

Setting up Barrier

After installing Barrier, you must go through the setup process to use it. Follow the step-by-step instructions below to configure the app.

Note: the app must be set up on both computers to work.

Step 1: Look for “Barrier” in your app menu and launch it.

Step 2: Upon launching Barrier, you will see a “Welcome” screen. Find the “Next” button to move to the next page.

Step 3: On the next page, you will see “Server or Client.”  Follow the instructions below to learn how to set up both the server and the client. Please note that only one PC may act as the server and share keyboard/mouse over LAN to other machines.

Client

If you plan to set up this PC to access the keyboard and mouse of another Linux PC remotely, select the “Client” option, and click the “Finish” button.

Server

To set up a Linux PC as the keyboard/mouse host for other systems, select the “Server” option, and click the “Finish” button. There is no need to configure IP address options or ports, as the Barrier app will do it automatically.

Share mouse and keyboard over LAN

To share your mouse and keyboard, do the following. First, go to the server PC, find the “Start” button, and click it to start the server.

Once the server is started on the host computer, go to Barrier on the client PC and uncheck the “Auto config” button. Then, in the “Server IP” write in the IP address of the PC hosting the server.

Note: unable to find the IP of the server? In Barrier, it will show the server’s IP next to “IP addresses.”

After entering the IP address, click the “Start” button to connect to the server. You will then be able to control the keyboard and mouse of the remote PC. To stop the connection to the server, click “Stop” in the Barrier client app.