3

I am using Wi-Fi hotspot on Android. Can I SSH into it from my laptop which is connected to hotspot? How would I do this?

2

You need to run an SSH server on your Android phone. There are apps available, but simple solution is to go for Termux. Install app, then install packages openshh and termux-auth. Set password and start server:

~$ pkg install openssh termux-auth
~$ passwd
~$ sshd

If you want to use key authentication instead of password, create key pair on client with ssh-keygen and copy the contents of ~/.ssh/id_rsa.pub to phone in ~/.ssh/authorized_keys (where Termux's $HOME is /data/data/com.termux/files/home), and restart server:

~$ pkill sshd
~$ sshd

Now on client:

~$ ssh <Phone_IP> -p 8022

No username is required as Termux is the only user which can be logged into. If you want default port (22) or a username or multiple user setup, visit the link given below.

RELATED:

  • Thank you. I did not realize termux was different from terminal emulator. Im curious, does it have its own applications etc? Like its own sh etc? – Kevin Jul 9 at 0:46
  • 1
    @Kevin yes it doesn't run Android's /system/bin/sh by default, instead its own package bash, modified for Android environment. – Irfan Latif Jul 9 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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