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

On Jan 10, 2010 7 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@192.168.1.100 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@192.168.1.100 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.

7 comments:

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 192.168.1.1-254 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
http://adf.ly/bRiK3

Devender said...

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

when i enter the command in terminal# ssh kmit@10.11.33.143 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

Post a Comment