As the title suggests, I want to use a remote keyboard locally. The remote keyboard should be usable in a TTY and, if possible, in the X-Server as well. Are there any drivers (kernel modules) emulating a "fake" keyboard with network transparency?

4 Answers 4


I found it out on my own.

First make sure you have loaded the evdev kernel module on both machines.

On the remote machine you run:

$ cat /dev/input/by-path/platform-i8042-serio-0-event-kbd | nc <IP> 4444

And on the client:

$ nc -l -p 4444 > /dev/input/by-path/platform-i8042-serio-0-event-kbd

(Note: If your're using netcat from netcat-openbsd, for example in Ubuntu or Fedora, don't use the '-p')

It works perfectly no matter whether I am in a TTY or in X.org. And it runs without any delay!

Unfortunately all keys are typed on the remote machine as well. Is there a way of temporarily disabling them while nc is running? I thought of somehting like running "cat -" on the remote machine but a Ctrl-C would make it end of course.

  • 2
    I had better luck with nc -l 4444, without the -p. According to man nc, -p is explicitly forbidden in combination with -l. Otherwise this is a fantastic solution and just what I needed :) Mar 13, 2011 at 11:28
  • 1
    I strongly encourage you to use it over secure connection or locally (though that ain't really secure either). There is snetcat, ('secure netcat') that can work if you import certificate (go, google it :-). Also, please accept your solution, this question is still 'open'. Apr 18, 2013 at 17:06
  • it would be greater if it supports copy and paste!! Jun 27, 2015 at 13:59
  • Amazing solution! I am impressed you managed to figure this out. Did you find a solution for disabling the output on one machine while running on the other?
    – Cestarian
    Apr 12, 2016 at 19:33
  • Please read Can I answer my own question? Dec 20, 2020 at 9:15

Synergy will share a keyboard over the network between multiple machines. If it doesn't directly do what you want, I'm sure there's code there that will make it easy for you to set up.

  • Synergy+ is a 'fork' of synergy that is still maintained for bugfixes. Additionally quick-synergy is available in some Debian package repositories and provides a GUI wrapper for synergy.
    – Josiah
    Nov 8, 2009 at 22:41
  • 3
    Actually Synergy depends on the X-Server. I need a solution that works in a TTY though. If I knew how to emulate key presses in a TTY, I would try to write a small application myself. Unfortunately I was not able to find anything valuable on Google. Perhaps someone can give me some hints?
    – timn
    Nov 9, 2009 at 17:26

Take a look at Synergy.

Synergy is Free and Open Source Software that lets you easily share your mouse and keyboard between multiple computers, where each computer has its own display. No special hardware is required, all you need is a local area network. Synergy is supported on Windows, Mac OS X and Linux. Redirecting the mouse and keyboard is as simple as moving the mouse off the edge of your screen.



The above suggestion of using nc (netcat) doesn't work for me.

I can open the input stream using this command:

nc -l -p 4444 > /dev/input/by-path/platform-i8042-serio-0-event-kbd

I get permission denied, even if I do it as sudo. The target machine has a really old linux install on it, so maybe /dev/input device files were read-only way back when.

I was able to solve this problem using x2x, however, and the result is very user-friendly.

You need to do "xhost +" on the target machine, and also use gdmsetup to enable remote connections (this removes the -nolisten flag for X the next time gdm launches an X session).

After that, your xserver is wide open for remote connections, and x2x can connect to it from the source (keyboard) machine

x2x -to

The cool thing about x2x is that it gives you a little control window on the source machine, and keyboard events are only sent to the target when that window is focused. This is a very handy way to do it (I'm typing this answer from the source machine right now, and no stray keypresses are reaching the target machine, because I have the control window de-focused). Also, clicking on the center of the control window starts forwarding mouse events as well, and 2-button clicking ends the sending of mouse events. Also, when you enable mouse forwarding with a click in the control window, ALL keyboard events are sent to the target, and none to the source. Thus, ALT-TAB is sent to the target without defocusing the control window on the source machine.

I have virtual desktops enabled on the source machine, so I just stick the x2x control window on a distant desktop and only go there when I need to control the target machine.

This version of the solution is at the X level, where the above answer is at the linux device level. Of course, this won't work at all if you're not running X on both the target and the source.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.