Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh into Android to send WOL packet [closed]

I want to WakeOnLAN my NAS server remotely, but my router blocks WOL packets. I thought I could circumvent this by ssh'ing into our androidTV box, and sending a WOL packet from there on the LAN. I can ssh into the androidTV, but can't send the WOL packet. Is it possible to run a graphical ssh session to the androidTV and then use one of the WOL apps in the Play Store? Or is there any way I can use a WakeOnLan application from terminal?

like image 639
Matthijs Vk Avatar asked Nov 22 '22 09:11

Matthijs Vk


1 Answers

I have figured out the solution as I was trying to achieve the same thing.

Problem: I need to remotely power on my server at home using Wake on Lan (WoL) command. For WoL to work reliably, a PC within the LAN needs to be used to send the WoL command, and NOT a remote PC. I don't completely understand the reason why, but it has something to do with the router clearing the ARP table cache after a device is powered off. In our case, the server that is switched off but we want to remotely turn it on. For more details read here: https://serverfault.com/questions/161560/how-to-get-wake-on-lan-working/349783#349783

Solution You can have a device within the LAN which can send the WoL command to the powered off server. One way to do this is by having a rooted Android device which is running a SSH server. You can remotely login to the Android device using SSH and then send the WoL command.

Steps I used

  1. Root an Android device and ensure you have BusyBox installed
  2. Install a SSH server on the Android. https://android.stackexchange.com/questions/9905/is-there-some-ssh-server-for-android. I used SSHDroid.
  3. Remotely login to your Android device using SSH. Ex: ssh -p 2222 [email protected]
  4. Send the WoL command using ether-wake -b -i wlan0 XX:XX:XX:XX:XX:XX. Reference: https://forum.xda-developers.com/showthread.php?t=2495288
  5. Steps 3 and 4 can be combined in one go using this example: ssh -p 2222 [email protected] "su -c ether-wake -b -i wlan0 XX:XX:XX:XX:XX:XX"

Note:

  • The above steps may differ based on the type of device. The update steps are for an Android device, but the same principle can be used on non-Android devices.
  • On Android you can NOT use the wakeonlan command. You have to use ether-wake command. This is because BusyBox doesn't install wakeonlan.
  • You must have sudo or root privileges to issue the ether-wake command
like image 171
Zythyr Avatar answered Nov 23 '22 23:11

Zythyr