How can I communicate with Android device via SSH?

How can I connect to an Android device from my computer using SSH?

Usually on the network, if you know the user ID and password of the Linux machine (with the SSF server turned on), you can connect from another device.

(How) can this be done on Android?

+46
android linux ssh networking
Jul 13 2018-12-12T00:
source share
4 answers

Check out xda-developers.com - Pro-Tip # 2: Wireless and Shell . It explains how to run an SSH server on your Android device using QuickSSHd or SSHDroid.

+23
Jul 13 2018-12-12T00:
source share
— -

SSH Server Applications

The SSHDroid app is an opportunity, and there are many others on Google Play (search for SSHD ).

  • Get your Android and PC on the same local network.

  • Open SSHDroid

  • Pay attention to the "Address" field shown in the application. It should look something like root@192.168.0.3:2222 .

    You can also use netcfg + adb to get the IP address of the device with the CLI.

  • Install the SSH client on your computer, for example:

     sudo apt-get install openssh-client 

    on Ubuntu 15.10

  • Launch on PC:

     ssh root@192.168.0.3 -p 2222 
  • It says:

     Default password is 'admin' root@192.168.0.3 password: 

    So enter admin and enter.

  • We are here. Try ls . But note:

    • many folders are not accessible without using your device. In particular, each application has its own Linux user, and you register as an SSHDroid user.

    • The Android device is not a POSIX system , and in particular POSIX CLI utilities may not be available, for example. cal (how could you live without this?)

  • The SSH server continues to run on Android as a daemon, even if the SSHDroid window is closed. To stop it, you have to go to the application and press STOP .

I also tried SSH Server from Ice Cold Apps . It is definitely more powerful, allowing multiple connections and other protocols, but it requires a bit more configuration.

Tested on Ubuntu 15.10, Android 5.1.1. SSHDroid 2.1.2.

adb usb shell

If you just want to quickly get a shell on a USB device to help with development, install the SDK , enable debugging, and follow these steps:

 adb shell 

This is an easier way.

I just came here because I had never worked on Android development before and never thought: I need a shell on another computer ... SSH! But sometimes mobiles are different.

To transfer files you want adb pull and adb push .

adb TCP shell

If you don’t have USB access to the device, you can also connect the adb shell through TCP, which provides a solution very similar to ssh.

More: How to connect to Android with ADB via TCP?

+27
Dec 02 '15 at 10:36
source share

install "termux" from the Google play store. It provides a brilliant environment for debian apt.

continue to install the ssh client and / or server just by typing

apt install openssh

Using ssh

For more information go to: https://termux.com

+4
Nov 21 '16 at 6:37
source share

You will need

Your Android Phone (Rooted and with Wi-Fi)

SSHDroid (SSH server)

PuTTY.exe (SSH client)

Configure SSHDroid

Install "SSHDroid" from the Android market on your phone, this will turn your phone into an SSH server.

For the first time you need to configure a password to enter the shell. The default password is the administrator, which you can change for the first time.

Putty setup

Download PuTTY.exe for SSH Client on your Windows PC, it comes in one executable file, so you do not need to install it, just double-click on it and PuTTY will start.

There is no need to configure anything in PuTTY.

Lets run

The first step is to launch Wi-Fi and connect your Android phone to the target PC, and then launch the SSHDroid server on your mobile phone, but before that, make sure that in the SSHDroids application window click "Settings" → "Require WiFi", see above fig. screen 2. And then click the "Start" button.

Once the SSH server has been successfully launched, it will display the IP address of your mobile phone in the color of the sky, like this root@192.168.43.129, as shown on screen 4.

Take the IP “192.168.43.129” and enter it in the PuTTY host field (PC) and click “Connect”. Make sure the port number is 22, as shown in the second figure.

It will ask the certificate to click ok, and then the command prompt window will appear, enter "root" hit enter and enter the password for the root user, the default is "admin", as I mentioned earlier. After a successful login, you will be able to use Linux commands such as ls, reboot -f, mkdir, find, etc.

If your phone is connected to the Internet, you can also use network commands such as ping, wget, telnet, etc.

Source: - How to connect an Android phone to a PC using SSH and putty

-one
Apr 7 '15 at 9:25
source share



All Articles