33

I want to use one PC as a USB keyboard for another PC. It has to be indistinguishable from actual USB keyboard. How can I achieve this?

A solution that works with any of Ubuntu Linux 14 and above, OS X 10.11 or Windows 10 would be acceptable. Should work with USB 2.0 or 3.0.


Update: The machine to receive the input should not require any specific software installed or network access. I need to use a physical USB cable and the destination machine should react as if a physical keyboard is present on that USB port.

Giacomo1968
  • 58,727
miguelv
  • 447

9 Answers9

17

You could use a Raspberry Pi Zero in USB gadget mode. In this mode, the Raspberry Pi can behave as many standard USB devices (keyboard, mouse, mass storage, etc.) and you will then be able to e.g. "inject" keystrokes from a program running on the Pi (and you can then control this program remotely as you see fit).

The Raspberry Pi Zero is not the only device allowing this; but it's cheap, it's easy to get one, and there are many documentations out there explaining how to do this, so it's (IMHO) a pretty good starting point for a project like this!

jpetazzo
  • 334
7

I have had success with etherkey, a Teensy and a UART to USB bridge.

The host computer sends commands to the Teensy through the UART bridge. The Teensy pretends it is a keyboard and presses virtual buttons on the other PC. Etherkey is the software that runs on the Teensy and forwards keys from the host computer to the virtual keyboard.

The destination computer detected the new "keyboard" immediately and didn't need any setup.


Update: I also got an Etherkey running on a ATmega32u4 development board, which is more easily available and cheaper than the Teensy.

Giacomo1968
  • 58,727
Sjoerd
  • 1,448
6

I eventually found a hardware device to do this on AliExpress. That makes it a bit of a black box, though I suspect internally it operates much like in the answer from Sjoerd.

The USB end of the device appears as a HID keyboard to the host, and I can connect to the serial end from another computer and send it characters which will then be 'typed'. There are some special patterns to allow modifier keys. If the sending computer doesn't have a real serial port, a common USB-Serial adapter can be used with this as well, though that makes it harder to tell which end is pretending to be the keyboard.

This was by far the cheapest solution I've found, ~$10 USD, compared to other products I've seen listed around $100 or more. If I needed more and the AliExpress product disappeared, I would try the Teensy solution.

enter image description here

4

You can use usbip to make USB devices (including a keyboard) on a host computer available as USB devices on a client computer over the network. As it's a USB device, it will be indistinguishable from any USB device attached locally.

Clients exist for Windows, and usbip has been a standard part of the kernel for a long time. Under Debian and Ubuntu, the usbip package contains the programs to set up and control such a connection.

Details on how to set it up can be easily googled, e.g. here.

Similar questions:

Giacomo1968
  • 58,727
dirkt
  • 17,461
4

This is possible with a CH9329 chip. The CH9329 converts UART to USB keyboard.

Here's a cheap USB-to-USB cable with both a CH340 USB-to-UART and a CH9329 UART-to-USB-keyboard:

Here's software to send keystrokes over the UART:


Update: This works. I purchased a CH9329+CH340UART/TTL Serial Port to USB HID Full Keyboard and Mouse Drive-free Dual Male Module. On the small end, this presents as a CH340 serial port. On the big end, it presents as a "WCH UART TO KB-MS_V1.8" keyboard. I used the ch9329 Python module to send keystrokes:

from serial import Serial
from ch9329 import keyboard

ser = Serial("/dev/tty.usbserial-1110", 9600, timeout=0.05) keyboard.write(ser, "Hello World\n") ser.close()

The cable can type at a rate of 23 characters per second. However, the ch9329 Python library has additional delays that reduces this to 12 characters per second.

Sjoerd
  • 1,448
3

I'm facing the same situation (specific scenario: I need to unlock my workstation remotely from the PRE-OS BitLocker screen). I've ordered the following HW, so I'm posting this to share my research, but not my experiences

The 'source' computer has the following:

This should provide the source machine the same functionality as this $500 USB all-in-one.


The 'target' computer has the following:

  • HDMI splitter so I can still have console when I'm at the computer. Lower-end devices can be found on Amazon for $15 USD.

Total cost will be ( $20 + $90 + $15 ) * 2 = $250 USD so each computer in the pair can monitor and manage the other machine from POST to OS fully online (run level 5).

Wish me luck getting my admin to approve this expense!

Giacomo1968
  • 58,727
2

Given the time between the OP and now, this may be moot. However, for any others with a similar question, I propose the following solution:

  1. Buy a cheap USB keyboard, the ones that are like $5 to $20 or so.
  2. Disassemble it and take the controller and USB plug section, then wire-up your "controller" to the contact connections intended for the keyboard matrix. (It goes without saying, that soldering will be required.)
  3. Map out the pins either by examining the contact matrix, or by program.
  4. Craft your control program using the mapping.
  5. Set your program to load and run OnBoot and off you go!

The control program can be written in any language with that supports the manner of output that will control the "key" matrix inputs of the keyboard controller, and the usb end plug, plugs into the target computer as a usb keyboard as desired.

If using a Linux based OS, Python is likely your language of choice. If using a Windows based OS, .Net is likely your language of choice (specific flavor C#, VB is up to you). It's likely even Node.js or PHP could be used if you can control GPIO or Parallel port pins.

Happy Hacking!

Giacomo1968
  • 58,727
1

Use Logitech Unifying USB receiver and emulate virtual keyboard with this:

Should be about $20 total.

Giacomo1968
  • 58,727
1

One possible solution is to add a Bluetooth dongle to the target PC, and emulate a Bluetooth keyboard from the host PC.

Giacomo1968
  • 58,727
Sjoerd
  • 1,448