0

As in title: How can I turn off an Android phone in the same Ethernet remotely using a Windows computer?

They are in the same Local Area Network and connected to the same router, the Android phone is connected to the router via WiFi and the Windows computer is connected to the router via a cable.

I have tried numerous times to get a solution using Google search with different keywords, and objectively Google isn't very competent in understanding complex sentences and I can't get what I am looking for, see for yourself what the results Google gave: Google: How can I turn off an Android phone in the same Ethernet remotely using a Windows computer?, most of the results are exactly the opposite of what I intended to achieve.

I want to connect to the phone wirelessly and send commands through WiFi.

I figure I need to use either Telnet or SSH to do this, log into the Android device remotely and use Android terminal commands to shutdown the phone.

Unfortunately I have tried telnet and here is the result:

C:\Windows\System32>telnet 192.168.1.3
Connecting To 192.168.1.3...Could not open connection to the host, on port 23: Connect failed

I know what this means, this is because telnet port is not open and the telnet server isn't online on the Android phone by default.

So naturally I need to install some application on the Android phone that runs the telnet/SSH server and opens the telnet/SSH port, and setup a login and password, so I can connect to the phone remotely and it has to somehow execute the commands.

The phone isn't rooted, but I have Android Studio and the phone does have USB Debugging, what tweaks do I need to make in order to enable remote logging?

And I don't know how to use Android terminal, is there even a command line interface shell on Android? I don't have any experience with this, however from what I have learned Android is based on Linux and I have some experience in Ubuntu 20.04 LTS WSL, I know I can use these commands:

sudo power off
shutdown -h now

Android must use something similar.

How can I achieve this?


The suggested duplicate: How can I shutdown my Android phone using an adb command? doesn't answer my question because it shuts down the phone through USB while I have explicitly stated in my question that I want to shutdown the phone wirelessly through WiFi connection.

3
  • Does this answer your question? How can I shutdown my Android phone using an adb command? (note adb over Wifi has to be enabled first)
    – Robert
    Commented Feb 8, 2021 at 12:22
  • adb shell reboot -p Commented Feb 8, 2021 at 12:30
  • The solutions in the linked duplicate merely uses adb to execute commands in a shell. If you can find a way to do that without using usb (adb wireless /ssh) than they would work pretty much the same way.
    – Firelord
    Commented Feb 8, 2021 at 13:08

1 Answer 1

0

Shutdown as a command requires root

The simple answer is you can't perform a shell command from within an app for shutdown an Android system unless your device is rooted.

For performing the shutdown command on Android special permissions are required. When triggering a shutdown via UI the command is internally forwarded to a component that has the permissions to shutdown the system.

But regular apps (and therefore this applies also to all processes like telnet or ssh started in the context of an app) don't have this permission and thus can't shutdown the system.

Workaround: shutdown via adb over IP

Executing the command shutdown -p via adb should power off your phone.The problem is that adb by by default only available via USB connection (if you have enabled developer options and adb). The only workaround would be to connect your phone after booting to a PC and enable adb access via IP. This would be then allow a sort of telnet (via "adb connect IP" instead of telnet).

Warning: ADB over IP is really equivalent to telnet which means that it's data is transmitted totally unprotected in plain text on network level. Therefore you should use adb over IP only in safe networks.

See also this question: How can I shutdown my Android phone using an adb command?