Share Your Keyboard and Mouse Between Linux and Raspberry Pi – It's FOSS

It's FOSS
A Linux and Open Source Web Portal
Last updated By 56 Comments
This DIY tutorial teaches you to share mouse and keyboard between multiple computers using open source software Barrier.
I have a multi-monitor setup where my Dell XPS running Ubuntu is connected to two external monitors. I recently got a Raspberry Pi 4 that has the capability to double up as a desktop. I bought a new screen so that I could set it up for monitoring the performance of my cloud servers.
Now the problem is that I have fours screens and one pair of keyboard and mouse. I could use a new keyboard-mouse pair but my desk doesn’t have enough free space and it’s not very convenient to switch keyboards and mouse all the time.
There are two ways to handle this issue:
If you can spend some money, go for the hardware solution. I have started using Dell KM717 wireless keyboard and mouse pair. It allows connecting to three devices, one by RF receiver and the other two by Bluetooth. You can switch between the three separate computers using the switch on the keyboard and mouse. It’s really convenient.
Another way to tackle this problem would be to buy a kvm switch. This is a handy gadget that allows you to use the same display screen, keyboard and mouse between several computers running various operating systems. You can easily find one for around $30 on Amazon.
If you cannot go for the hardware solution, try the software based approach to share the keyboard and mouse between computers.
I used Barrier, an open source fork of the now proprietary software Synergy. Synergy Core is still open source but you can’t get encryption option in its GUI. With all its limitation, Barrier works fine for me.
Let’s see how you can use Barrier to share mouse and keyboard with multiple computers. Did I mention that you can even share clipboard and thus copy paste text between the computers?
I have prepared this tutorial with Ubuntu 18.04.3 and Raspbian 10. Some installation instructions may differ based on your distribution and version but you’ll get the idea of what you need to do here.
The first step is obvious. You need to install Barrier in your computer.
Barrier is available in the universe repository starting Ubuntu 19.04 so you can easily install it using apt command.
You’ll have to use the snap version of Barrier in Ubuntu 18.04. Open Software Center and search for Barrier. I recommend using barrier-maxiberta
On other distributions, you should enable Snap first and then use this command:
Barrier is available in Debian 10 repositories. So installing barrier on Raspbian was easy with the apt command:
Once you have installed the software, it’s time to configure it.
Barrier works on server-client model. You should configure your main computer as server and the secondary computer as client.
In my case, my Ubuntu 18.04 is my main system so I set it up as the server. Search for Barrier in menu and start it.
You should see an IP address and an SSL fingerprint. It’s not entirely done because you have to configure the server a little. Click on Configure Server option.
In here, you should see your own system in the center. Now you have to drag and drop the computer icon from the top right to a suitable position. The position is important because that’s how your mouse pointer will move between screens.
Do note that you should provide the hostname of the client computer. In my case, it was raspberrypi. It won’t work if the hostname is not correct. Don’t know the client’s hostname? Don’t worry, you can get it from the client system.
On the second computer, start Barrier and choose to use it as client.
You need to provide the IP address of Barrier server. You can find this IP address on the Barrier application running on the main system (see the screenshots in previous section).
If you see an option to accept secure connection from another computer, accept it.
You should be now able to move your mouse pointer between the screens connected to two different computers running two different operating systems. How cool is that!
Now that you have setup Barrier and enjoying by using the same mouse and keyboard for more than one computers, what happens when you reboot your system? You need to start Barrier in both the systems again, right? This means that you need to connect keyboard-mouse to the second computer as well.
Since I use Wireless mouse and keyboard, this is still easier as all I need to do is to take the adapter from my laptop and plug it in the Raspberry Pi. This works but I don’t want to do this extra step. This is why I made Barrier running at the start on both systems so that I could use the same mouse and keyboard without any additional step.
There is no autostart option in the Barrier application. But it’s easy to add an application to autostart in Ubuntu. Just open the Startup Applications program and add the command barrier-maxiberta.barrier here.
That was the easy part. It’s not the same in Raspberry Pi though. Since Raspbian uses systemd, you can use it to create a new service that will run at the boot time.
Open a terminal and create a new file named barrier.service in /etc/systemd/system directory. If this directory doesn’t exist, create it. You can use your favorite command line text editor for this task. I used Vim here.
Now add lines like these to your file. You must replace 192.168.0.109 with your barrier server’s IP address.
Save your file. I would advise to run the command mentioned in ExecStart line manually to see if it works or not. This will save you some headache later.
Reload the systemd daemon:
Now start this new service
Check its status to see if its running fine:
If it works, add it to startup services:
This should take care of things for you. Now you should be able to control the Raspberry Pi (or any other second computer) with a single keyboard mouse pair.
I know that these DIY stuff may not work straightforward for everyone so if you face issues, let me know in the comments and I’ll try to help you out.
If it worked for you or if you use some other solution to share the mouse and keyboard between the computers, do mention it in the comments.
Like what you read? Please share it with others.
Filed Under: Tutorial
Creator of It’s FOSS. An ardent Linux user & open source promoter. Huge fan of classic detective mysteries ranging from Agatha Christie and Sherlock Holmes to Detective Columbo & Ellery Queen. Also a movie buff with a soft corner for film noir.
Pour le moment j’utilise un clavier RF et une souris RF/Bluetooth.
Je dois cependant transférer le récepteur RF-USB d’une machine à l’autre. Pour la souris, je change l’interrupteur de RF à Bluetooth pour accéder au RPi4B. Je suis à la recherche d’un clavier RF/Bluetooth à prix raisonnable.
Thank you!!! This is awesome!
Glad you like it 🙂
I have been looking for something like this for YEARS . I am in tears as i see the mouse going between my Kali Linux and Windows . Thank you very much for this post .
This is Gold .
This is all i needed .
I can live happily from here on .
THANK YOU .
Happy to be of help, Steve. Enjoy it 🙂
Hi again I tried optional part on both server and client (Fresh Install) and got following errors.
[email protected]:~ $ systemctl status barrier.service
* barrier.service – Barrier Client mouse/keyboard share
Loaded: loaded (/etc/systemd/system/barrier.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-06-02 03:16:16 BST; 10s ago
Process: 13150 ExecStart=/usr/bin/barrierc –no-restart –name raspberrypi –enable-crypto 192.168.0.16 (code=exited, status=0/
Main PID: 13151 (barrierc)
Tasks: 3 (limit: 1938)
CGroup: /system.slice/barrier.service
`-13151 /usr/bin/barrierc –no-restart –name raspberrypi –enable-crypto 192.168.0.16
Jun 02 03:16:16 3Home systemd[1]: Starting Barrier Client mouse/keyboard share…
Jun 02 03:16:16 3Home systemd[1]: Started Barrier Client mouse/keyboard share.
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: started client
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: connecting to ‘192.168.0.16’: 192.168.0
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] INFO: OpenSSL 1.1.1d 10 Sep 2019
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: server fingerprint: 82:F2:9D:E6:AB:60:A
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] ERROR: failed to verify server certificate fingerprint
lines 1-16/16 (END)
Client:
[email protected]:~ $ systemctl status barrier.service
* barrier.service – Barrier Client mouse/keyboard share
Loaded: loaded (/etc/systemd/system/barrier.service; disabled; vendor preset: enabled)
Active: active (running) since Wed 2021-06-02 03:16:16 BST; 10s ago
Process: 13150 ExecStart=/usr/bin/barrierc –no-restart –name raspberrypi –enable-crypto 192.168.0.16 (code=exited, status=0/SUCCESS)
Main PID: 13151 (barrierc)
Tasks: 3 (limit: 1938)
CGroup: /system.slice/barrier.service
`-13151 /usr/bin/barrierc –no-restart –name raspberrypi –enable-crypto 192.168.0.16
Jun 02 03:16:16 3Home systemd[1]: Starting Barrier Client mouse/keyboard share…
Jun 02 03:16:16 3Home systemd[1]: Started Barrier Client mouse/keyboard share.
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: started client
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: connecting to ‘192.168.0.16’: 192.168.0.16:24800
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] INFO: OpenSSL 1.1.1d 10 Sep 2019
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] NOTE: server fingerprint: 82:F2:9D:E6:AB:60:A4:92:B3:9F:CE:04:EE
Jun 02 03:16:16 3Home barrierc[13151]: Barrier 2.2.0-Release: [2021-06-02T03:16:16] ERROR: failed to verify server certificate fingerprint
Same Error received on both server and client
Any Idea why?
Join 75,000 other Linux users and start your journey to become a better, informed desktop Linux user.
It’s FOSS is Part of chmod777 Media Tech (OPC) Pvt Ltd· Built on Genesis Framework and Powered by UpCloud
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.

source

We will be happy to hear your thoughts

Leave a reply

LINXGO
Logo
Compare items
  • Total (0)
Compare