Tuesday, August 27, 2013

Magic Reboot: When SSH gets stuck

If you ever need to reboot a host, but you cannot SSH in (you have the password, but the session is frozen), you can use the magic reboot method. Here it is:

ssh root@ "echo b > /proc/sysrq-trigger"

This will tell host to write b to the /proc/sysrq-trigger file. This will cause an immediate reboot of the host.

Using SCP to send a file to another host

If you can SSH into a host, you can use SCP to send a file securely to it. Here's an example:

scp foobar.txt root@

This will send the file foobar.txt to host as user root and save it to the /var/log directory. SCP will prompt you for a password for the root user, of course, but it works like a charm.