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?
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.
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.
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 192.168.1.3:0
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.