Let’s say you have two Linux computers, and want to control both of them with only one set of keyboard and mouse, you can do this with x2x.

Install

Install x2x and OpenSSH server on the target computer ( the one where your keyboard and mouse is not physically connected to )

Debian based Linux

$ sudo apt install openssh-server
$ sudo aptitude install x2x

Arch based Linux

$ sudo pacman -S openssh
$ yay -S x2x-git

Connect

Get target computer’s IP by running this on target computer

$ hostname -I | awk '{print $1}'

Connect to target computer from controlling computer

$ ssh -XC username@ip x2x -west -to :0.0

Note:

  • replace username and ip accordingly
  • depending on the left right positioning of your computers, change west to east if you need it

Debug

You might get the error message

X11 forwarding request failed on channel 0
x2x - error: can not open display

Solution:

1.On the controlling computer, run

$ sudo vim /etc/ssh/sshd_config

2.Uncomment X11Forwarding yes (or put it in if there isn’t this line)

3.restart SSH server

Done

You can now move your mouse cursor to your target computer, and type as if your mouse and keyboard is connected to the target computer too.

Credits to distrotube’s video which led me to discover x2x.