I have a server running in multi-user mode that is connected to a keyboard and a monitor. On a separate computer, I would like to SSH to the server and run a program that captures input from the keyboard and prints text to the monitor. The keyboard and monitor will never be used for any other purpose.
Right now, when the server boots, a (text) login screen is displayed on the monitor. I know that I can write to the corresponding /dev/tty
device. However, the keyboard also writes to the same place.
How can I capture keyboard events and use a monitor as a text-display on Linux?
I may be missing some of the basics around hardware interfacing on Linux. What do I need to know?
Running out of bounty time - If someone wants to flesh this out further I'll award accordingly:
I did the following to prevent any login programs from starting:
systemctl mask serial-getty@ttyO0
systemctl mask systemd-logind
systemctl mask getty@tty1
Then I am running my program when required with:
openvt -c 1 -f /path/to/my/program
This would be a fully satisfying solution, except for that pesky -f
. What is running on tty1
? Is there anything I can do to stop it? Should I stop it?
Notably, this solution does meet all of my needs -- As far as I understand it, I am taking over the tty and thus get access to its stdin (receiving output from keyboard) and stdout (printing to monitor).
openvt
is for. – Henriquez/etc/systemd/logind.conf
to setNAutoVTs=0
andReserveVT=0
. Now no login prompt will be active and I can write to/dev/tty0
to print what I'd like. How can I then see what the keyboard is attached to? (ex. Alt-F2 will still try to change to tty2). – CymeExecStart
in/usr/lib/systemd/system/[email protected]
... how do I set the keyboard as stdin? – Cyme