Remote Shutdown and Remote Reboot on Linux (Ubuntu) with Just One SSH Command

On Jan 10, 2010 10 comments

Do you need to remotely shutdown or reboot a computer on your network? Do you want to do it with just one ssh command? The answer is here.

Type this command on your terminal :

$ ssh user@remote_computer sudo poweroff

example :

$ ssh john@ sudo poweroff

That command will make your computer going to shutdown. To reboot you need this command :

$ ssh user@remote_computer sudo reboot

example :

$ ssh john@ sudo reboot

That command will work nicely. But, you should notice that those two command will prompt you a password twice. To make it not ask you for a password you should copy you ssh key to your remote computer. And make poweroff and reboot command accessible by non root user.


Leo hammarskjöld said...

how do you find the names and ip of other on your network?

Rotua Damanik said...

Isn't there any GUI to do this?

Despenteado said...

nmap -sP or other subnet

saran sai said...

it was not work for my system
it displays a message like:

sudo: sorry, you must have a tty to run sudo

what can i do

Brian H Wilson said...

You might all see this as OBVIOUS but... If you do the "poweroff" command first then the "reboot" you will be disappointed! Since the power is OFF after the first command the reboot will not happen! ANYWAY

At the risk of compromising your security, if you put your personal key into the root authorized_keys file on the server then you can send commands to it as root without the sudo. The command would simply be "ssh root@remoteserver reboot" and there won't be any password prompts. Kaboom! Use at your own risk. YMMV.

mohammad rizwan said...

How To Remotely Shutdown A Computer

Devender said...

when I going turnoff in lan numbers of computers in ssh service

when i enter the command in terminal# ssh kmit@ sudo poweroff
> the error is like this "sudo: no tty present and no askpass program specified

and i need one more help how to connect 100 computers in at time in ssh service then need push softwares all computers

Unknown said...

> the error is like this "sudo: no tty present and no askpass program specified

Use "ssh -t" instead of just "ssh"

rose said...

Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.

AWS Training in Bangalore|

rohit said...

nice post thanks for sharing

Post a Comment