Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

The title can't be more specific. I'd like you to suggest the best way to send the poweroff instruction, to windows or Linux.

share|improve this question
    
"I'd like you to suggest an app" is definitely off-topic here. Please ask for solutions, not app recommendations. –  Al E. Sep 21 '12 at 18:37
    
I'll rephrase it then –  DeLiK Sep 21 '12 at 19:01
    
What kind of remote host and using wake on lan? –  roxan Sep 22 '12 at 2:36
add comment

4 Answers 4

If your host supports wakeup on lan you can use some of these apps.

share|improve this answer
add comment

If your network card can use Wake-On-LAN and/or is supported, and is remotely accessible, then yes, it is quite possible to achieve it (wake-on-lan apps are in abundance on the play store), taking into account of security considerations which is outside of the scope of this site, double check and make sure no other service is on that public facing PC otherwise bad guys will get in and wreak havoc.

share|improve this answer
add comment
up vote 1 down vote accepted

Power ON

  1. WOL enabled BIOS: In order to power up the remote host, you first have to enable WOL in his bios. The way you have to do this will vary from motherboard to motherboard, sou you'll have to figure it out by your self, or ask Google for some help.
  2. Remote Host cable connected to router
  3. Application capable of Sending Magic Packets to Remote.host's MacAdress

At the moment I'm using WOLdroid WOL Wake On Lan On remote.host execute:

ifconfig

Detect your remote.host's ehternet board usualy eth0 and save the HW Adress value XX:XX:XX:XX:XX:XX:XX

Enter that number when WOLdroid asks you for a mac adress. And your done.

Now you're able to powerup remotely

Power OFF

1. Prepare the Remote Host:

Remote host with Ubuntu 12.04

Create your private and public key files

To follow these steps you'll have to access your remote host, physically, or using another computer. I'll describe this as if you have physical access to the remote.host

Open a command window and install the ssh protocol:

sudo apt-get install ssh

Create public and private keys using ssh-key-gen

ssh-keygen

You should save the generated key in:

/home/yourusername/.ssh/id_rsa

Press enter twice to leave the passphrase empty.

Your identification has been saved in /home/yourusername/.ssh/id_rsa.
Your public key has been saved in /home/yourusername/.ssh/id_rsa.pub.
The key fingerprint is:
XX:XX:XX:xX:XX:xX:XX:XX:XX:XX:XX:XX:XX:XX yourusername@remote-host

Now copy the id_rsa.pub to your ~/.ssh/authorized_keys file with this command:

ssh-copy-id -i ~/.ssh/id_rsa.pub remote.host

Now you have to be able to execute the sudo shutdown -P 0 with no password.

Modify /etc/sudoers on remote.host with visudo

That way user "yourusername" can execute the shutdown command with no password asked.
Run:

sudo visudo

By running visudo, it leads to edit /etc/sudoers.
Add the line below to that file.

yourusername ALL = NOPASSWD: /sbin/shutdown

Now we are able to access remotely, and shutdown without passwords asked.

2. Prepare your Android

  1. Connect your android to the remote host and with your file explorer copy the id_rsa file located in ~/.ssh/ folder to the Android's SD card.
  2. Disconnect your android from the remote host
  3. Install a ssh client program. (ex. ConnectBot)
  4. Open Connect Bot and go to Manage Pubkeys > Import and select the key you copied later.
  5. Go back to Connect Bot's Main Scren and select the ssh protocol from the list and enter loginname@remote.host. Notice that it creates a line in the main screen with the data you input.
  6. Push it for a couple of seconds and select edit host.
  7. Select Use pubkey authentication and select id_rsa
  8. On Post-login automation write sudo shutdown -P 0
  9. Go back to you the Main Screen of Connect Bot and we're done!

Now you can Turn on and Shutdown a remote.host :)

share|improve this answer
    
That's not the right answer - as I've noticed - you've edited the question and dropped the reference to Windows PC.... why include linux? –  t0mm13b Sep 22 '12 at 14:59
    
I edited it again asking for a windows or linux solution, leaving the application preferences out of the question. –  DeLiK Sep 22 '12 at 22:17
add comment

Power On

You can simply enable Wake-on-LAN on your computer through BIOS setup, then use any of the several WOL apps to send the power-on command over the network. Some apps like SyncMe also include WOL functionality, so a separate WOL app may not be needed.

Shutdown on Windows

In general it will involve some server utility installed on the computer, and the client-side Android app communicating with it, for example oneID. These apps usually include other features, which may be overkill. You could use SSH and call the shutdown.exe utility, but it may be overkill too. Besides, these solutions may not shut down Windows "properly". For example, neither oneID nor shutdown.exe were able to trigger my "backup on logoff" routine.

HTTP Shutdown

For these reasons I end up writing my own small solution. HTTP Shutdown is a small web server which is going to shut down the computer when a specific HTTP GET request is received. That means you can turn off your computer from Android device by simply tapping a Tasker or web shortcut on home screen. Windows is going to shut down "properly", meaning your logoff scripts configured in Group Policy will get executed normally.

It requires Python and the PyWin32 library. Then you can run the server on computer startup like this for example: python http-shutdown.py 192.168.0.1 80 valid_password.txt. Then, on Android device you access the web address http://192.168.0.1/shutdown?auth=<password>. Server will respond in plain text with started if the shutdown has been started, denied if the password does not match the file contents, or something else otherwise.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.