0

Is there a command line (CLI) command to disable all keyboards on a machine, and then also a CLI command to re-enable them?

I'm on a laptop with an internal and external keyboard, I need to disable/enable both of them.

More Details

I'm on Ubuntu 22.04.3 LTS.

It should disable the keyboards across the board, it should not work anywhere at all (CLI, GUI, etc).

I'm creating a bash script that disables all keyboards for a finite time, once the time is up the script re-enables the keyboards.

  • 1
    How would you re-enable it from the command line if you have disabled the keyboards? Copy/paste? And what operating system are you using? If Linu, which one and which GUI? Is there a GUI? Is this only for non-GUI use? Please [edit] your question and give us some context. – terdon Nov 29 '23 at 15:54
  • So you want to disable the "harddrive", not just the tty? Nearly everibody uses keyboards, so it is built-in in the kernel, but you can (IIRC) build them as module, and so you can remove and install it again. Possibly you can do in the second layer (but I never see it as a problem, so not idea) – Giacomo Catenazzi Nov 29 '23 at 15:59
  • 1
    if X11 see xinput. If Wayland maybe this can help. – Andra Nov 29 '23 at 16:22
  • This is also highly relevant. – 01AutoMonkey Nov 29 '23 at 16:29

1 Answers1

0

check out usbguard, it is available in Redhat/CentOS/Rocky as an rpm. Not sure about ubuntu.

If you can get it to install on your distribution, it will work at making anything connected via usb not work (ask me how i know) - if your rules file does not allow it. It is a systemd service so conceivably it could be as simple as service usbguard start to disable everything if the rules file says deny all and doesn't allow anything, and service usbguard stop to then allow the usb connected keyboards and whatnot.

I don't know if it would affect a laptop internal keyboard, if those are still done via usb connection then it should.

https://usbguard.github.io/

check out the source code to see how they accomplish it: https://github.com/USBGuard/usbguard/releases

ron
  • 6,575