I know that Linux may, depending on configuration, allow the interactive user to reboot the server by pressing Ctrl-Alt-Del even without logging in. I have a remote console session over SSH to a remote server that I cannot log into, but I want to reboot it. Is it possible to somehow send the key combination Control-Alt-Delete over SSH (or telnet
)? If so, how?
Edit: to clarify, I am not just connected to the server's sshd
over ssh
- I am connected via a KVM over IP switch, so it's a serial console. But this connection itself is over SSH and my question is how to send the Ctrl-Alt-Del key combination over it.
You can use the Sysrq trigger in order to make an immediate reset (it's like pressing ALT-BREAK-b):
echo b >/proc/sysrq-trigger
BEFORE that, you might want to sync all filesystems, to not lose any data:
echo s >/proc/sysrq-trigger
This might only work if CONFIG_MAGIC_SYSRQ is enabled in your kernel. The possible keys are explained at Wikipedia btw.
If you are connected to a serial console and your kernel has
CONFIG_MAGIC_SYSRQ
and/proc/sys/kernel/sysrq
enabled (default on my Ubuntu machines), you can try BREAK, ALT-BREAK or CTRL-BREAK (depends on theSSH
to serial converter).If that works, you can press h (within 5 seconds) to get a list of available commands ("
s = sync filesystems
" and "b = force immediate reboot
" are maybe what you are looking for).For more information, have a look at linux/Documentation/sysrq.txt
In a comment you mention (ttyS0) - this isn't the local console, it's a serial console.
I don't think you can do Ctrl-Alt-Del from the serial console.
http://osdir.com/ml/linux.hardware.dell.poweredge/2003-01/msg00200.html suggests a way getting magic-sysrq working over serial - maybe this would be sufficient for rebooting a server?
The three-fingered reboot is only available from a local console.
It is handled by the following inittab line:
You would need to use the
shutdown
,halt
orreboot
commands from a shell with root privileges instead, if you don't have physical access to the machine.Look into a remote KVM switch to reboot without SSH access. http://en.wikipedia.org/wiki/KVM_switch#Remote_KVM_devices
Is it possible the command has been disabled? I regularly disable it on my production servers, usually to protect them from me when I forget that I'm logging into a Linux machine instead of a Windows machine and accidentally press Ctrl-Alt-Del and subsequently reboot the machine.
On machines which I do leave it so that a non-technical person can reboot, I extend the time in Dan's example from "now" to "2 minutes" so there's a sliver of a chance the reboot can be aborted if needed.
if you know the username/password of the remote machine, you can use SysInternals PSShutdown command to reboot a remote computer. Note, if you have gone to the trouble of forcing SSH to a KVM, your server is probably setup so that you can't reboot machines without logging in. In fact, its the default for servers from MS, if I remember correctly.
Isn't it easier to just issue "shutdown -h now", "reboot" or "halt" on the command line depending on what you prefer to happen to the machine?