Skip to content

Instantly share code, notes, and snippets.

@mjnaderi
Last active October 17, 2024 18:55
Show Gist options
  • Save mjnaderi/b933fe940cd47b09d5cfc14875e77d67 to your computer and use it in GitHub Desktop.
Save mjnaderi/b933fe940cd47b09d5cfc14875e77d67 to your computer and use it in GitHub Desktop.
Access Android Storage Remotely using Termux and SSH

References:

Steps

  1. Install Termux on android device.

  2. Find Termux username.

    $ whoami
    u0_a96
    
  3. Set a password.

    $ passwd
    
  4. Allow storage access:

    $ termux-setup-storage
    
  5. Install OpenSSH.

    $ pkg install openssh
    
  6. Start SSH server

    $ sshd
    $ pkill sshd  # for stopping the server
    
  7. Find IP of your android device.

    $ ip r
    192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.3
    
  8. Now you can SSH into your android device. You can access storage (/storage/emulated/0) because of termux-setup-storage

    $ ssh -p 8022 u0_a96@192.168.1.3
    
Copy link

ghost commented May 18, 2022

ssh -p 8022 u0_a96@192.168.1.3

@cardboardcode
Copy link

Hi @mjnaderi, thank you for providing this concise set of instructions. It has helped.

Just FYI for subsequent readers, please note the following: 📖

⚠️ 1. Regarding Step 1: Install Termux on android device,

Please ensure you install Termux via F-droid on your android device. Reason being the termux-mirror.ml repositories has been shut down since 2021, as stated by a Termux developer in the linked reddit post.

❌ Installing Termux via Google Play Store will result in your Termux app not being able to install any packages.

Reference: https://www.reddit.com/r/termux/comments/msn5rr/comment/gutlzt5/?utm_source=share&utm_medium=web2x&context=3

To install F-droid, please use the link below:
Link: https://f-droid.org/

⚠️ 2. Regarding Step 3: Set a password,

You will need to install termux-auth package beforehand. Otherwise, you will encounter an error stating you need to install it anyway:

pkg update
pkg install termux-auth

⚠️ 3. Regarding Step 7: Find IP of your android device.,

If you are trying to avoid using too much memory on your android device like me, running ip r would take up additional space by requiring you to install iproute2. Instead, just use ifconfig command as shown below:

ifconfig | grep inet 

@Yuvrajsingh14358
Copy link

Hay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment