UlyssesOfEpirus
Enthusiast
Enthusiast

Lock a USB keyboard to a VM so the host cannot disconnect it

Is it possible to associate a USB device firmly with a VM so it cannot be disconnected by the host user?

When a USB keyboard is connected to a VM, is it possible for malware in the host to log what keys are pressed?

If a USB keyboard cannot be locked and is disconnected, does the disconnection noise come from the guest or the host?

0 Kudos
3 Replies
avanish321
Expert
Expert

By default hid devices are forced to connect via host itself.

To connect an external keyboard and/or mouse directly to your virtual machine:

    Shut down the virtual machine that needs the mouse/keyboard.
    Plug the second mouse/keyboard into your host.
    Edit your virtual machine's .vmx file to include these lines:

    usb.generic.allowHID = "TRUE"
    usb.generic.allowLastHID = "TRUE"

    Power on your virtual machine.
    Go to VM > Removable Devices.
    Find and select your keyboard/mouse.
    Click Connect (Disconnect from host).

Note : If you connect the HID devices in such a way, you will not be able to use the keyboard on HOST.

Cheers! Avanish
UlyssesOfEpirus
Enthusiast
Enthusiast

Alright, done this and it works, host software should not be able to log key presses.

How do I prevent the hypothetical host hacker from disconnecting the keyboard from the VM while the VM is running?

0 Kudos
KingEzekiel
Contributor
Contributor

"Click Connect (Disconnect from host)."
"Note : If you connect the HID devices in such a way, you will not be able to use the keyboard on HOST." 

Is it possible to set the same keyboard to be used on a host computer? 
use Click Connect (without Disconnect from host).

0 Kudos