Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is it possible to execute Magic SysRq keys on remote machine, using SSH? For example I'm trying to run like this:

xdotool key Alt+Sys_Req+H

But I do not see any help in console, also in /var/log/syslog.

Please assume that I do not have root access, and I can't write to /proc/sysrq-trigger.

share|improve this question
    
If it was possible without root access, you'd have a big security hole. –  Stéphane Chazelas Feb 20 at 9:29
    
I was thinking that it is possible to send keystrokes via ssh. I'm using Ubuntu, here I can press Alt+SysRq+H as usual user, not root, and get help message. –  c0rp Feb 20 at 9:37
    
But you're a physical user typing on a USB keyboard connected to the machine, not some random unprivileged process on the system. Note that most systems restrict what sysrq keys are accepted over the keyboard as well. –  Stéphane Chazelas Feb 20 at 9:43
    
Thanks! If you write this information in answer, I will be able to mark question as answered –  c0rp Feb 20 at 9:45

2 Answers 2

This should work if sysrq is enabled in the kernel (tested live on my machine):

# echo "h" > /proc/sysrq-trigger

Requires root access.

The SysRq keys are not regular keys handled by X, thus xdotool can't trigger the magic keys because it interacts with Xorg itself, not the kernel. Thankfully the kernel provides a special file to trigger them from scripts and remote shells.

Tested on mine with an emergency sync command (S):

# echo "s" > /proc/sysrq-trigger
# dmesg | tail -n 2
[263565.001982] SysRq : Emergency Sync
[263565.115168] Emergency Sync complete
share|improve this answer

I was curious to see if you could inject the SysRq keypress using the Linux uinput device, so I added some code to another small project and it seems to be possible. But as was already noted, of course you need to have root access for this as well.

For this particular key combination, I'd have to execute:

./sendevtkeys /dev/uinput 56 99 35

where 56 corresponds to Alt, 99 to SysRq and 35 to h.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.