4

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.

chicks
  • 3,793
  • 10
  • 27
  • 36
EMP
  • 5,172
  • 10
  • 37
  • 33
  • 3
    Read your KVM documentation. It should have a way to invoke keychords, especially given you have to use Ctrl-Alt-Del to log into Windows. – kmarsh Aug 05 '09 at 12:08

8 Answers8

7

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.

Flimzy
  • 2,454
  • 18
  • 26
Martin
  • 71
  • 1
  • 1
4

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 the SSH 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

chicks
  • 3,793
  • 10
  • 27
  • 36
skettler
  • 91
  • 1
  • 5
1

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?

Douglas Leeder
  • 2,745
  • 18
  • 15
0

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.

Brian
  • 1,233
  • 2
  • 14
  • 25
0

The three-fingered reboot is only available from a local console.

It is handled by the following inittab line:

# What to do at the "Three Finger Salute".
ca:12345:ctrlaltdel:/sbin/shutdown -r now

You would need to use the shutdown, halt or reboot commands from a shell with root privileges instead, if you don't have physical access to the machine.

Dan Carley
  • 25,617
  • 5
  • 53
  • 70
  • Thanks, but I am at the local console (ttyS0) - just remotely over a KVM-IP device, which uses SSH. – EMP Aug 05 '09 at 11:19
  • Ahh, I see. Do you know the make/model of KVM? I would have thought it provided a break-out menu for such escape sequences. – Dan Carley Aug 05 '09 at 11:39
  • No, I don't know the model - it's provided by the DC. I suspect there's one KVM for multiple machines, too, so I don't have full access to it, only to my server. – EMP Aug 05 '09 at 12:49
  • I would hazard then that it is probably not possible. – Dan Carley Aug 05 '09 at 13:05
0

Look into a remote KVM switch to reboot without SSH access. http://en.wikipedia.org/wiki/KVM_switch#Remote_KVM_devices

Boohbah
  • 134
  • 5
  • I am connected over a remote KVM device - but I don't know how to make it reboot the server. I don't have any menu or anything, I just see the server's screen (in text mode, of course). – EMP Aug 05 '09 at 11:25
  • What is the brand/model of KVM? – MathewC Aug 05 '09 at 12:09
0

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.

Keith Stokes
  • 907
  • 5
  • 7
-2

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?

Robin Smidsrød
  • 233
  • 1
  • 4
  • 1
    He said that he is unable to login to the the server, so I don't think that will work. I also don't think he will be ablt to use ctrl-alt-del either – Sam Cogan Aug 05 '09 at 11:07
  • 1
    Allowing ctrl-alt-del over a non-logged in SSH session sounds like a horrible idea! Just think, you'd be able to reboot *any* server you could open an SSH connection with! – Brian Knoblauch Aug 05 '09 at 11:12