sodcalculator

10 Tech How-To

SSH into Android from PC: Step-by-Step Guide

Guide 10-56172 · Updated · Step by step

This guide shows you how to securely access your Android device’s file system and shell from a computer using SSH (Secure Shell). You’ll be able to transfer files, run commands, and manage your phone remotely over your local network. Before starting, you need to install an SSH server app on your Android device and have a computer with an SSH client (built into Linux and macOS, and available on Windows 10/11).

What You’ll Need

  • An Android device (Android 7 or newer recommended) with internet or local Wi-Fi.
  • An SSH server app installed on Android (e.g., SimpleSSHD, Termux, or SSHelper).
  • A computer with an SSH client (Windows 10/11 has OpenSSH built-in; Linux/macOS have it by default).
  • Both devices connected to the same local network (or reachable over the internet if you configure port forwarding).
  • Android device’s IP address and SSH port (default is usually 2222).

Step-by-Step

  1. Install an SSH server on Android. Open the Google Play Store and install an SSH server app. Two common choices are SimpleSSHD and Termux. For this guide, we’ll use SimpleSSHD as it’s straightforward.
  2. Start the SSH server. Open the app and tap the start button. The app will display a username (usually “root” or your device’s username) and a port number (default 2222). Write these down.
  3. Find your Android device’s IP address. Go to Settings > Wi-Fi, tap the connected network, and look for “IP address” (e.g., 192.168.1.10). Alternatively, the SSH app may show the IP address on its main screen.
  4. Open a terminal on your computer. On Windows, press Win + R, type cmd, and press Enter. On macOS, open Terminal (Finder > Applications > Utilities > Terminal). On Linux, open your terminal emulator.
  5. Connect via SSH. In the terminal, type the following command, replacing username with the username shown in the app and 192.168.1.10 with your device’s IP address, and 2222 with the port number:
    ssh username@192.168.1.10 -p 2222

    Press Enter.

  6. Accept the host key. The first time you connect, you’ll see a warning about the host’s authenticity. Type yes and press Enter to continue.
  7. Enter your password. The SSH app will ask for a password. By default, SimpleSSHD uses a password you set during setup. Type it and press Enter.
  8. You’re in! You should now see a shell prompt on your Android device. You can run commands like ls to list files, cd to change directories, and pwd to show the current directory.
  9. Transfer files (optional). To copy files from your computer to Android, use SCP (Secure Copy) in another terminal window:
    scp -P 2222 /path/to/local/file username@192.168.1.10:/sdcard/Download/

    To copy from Android to your computer, reverse the paths:

    scp -P 2222 username@192.168.1.10:/sdcard/Download/file.txt /path/to/local/folder/
  10. Stop the server when done. On Android, open the SSH app and tap the stop button to close the server and save battery.

Common Mistakes

  • Using the wrong port. Many SSH servers use port 2222, not 22. If you forget the port, the connection will fail.
  • Entering the wrong IP address. Double-check the IP address; it can change if the device reconnects to Wi-Fi.
  • Forgetting the username. SimpleSSHD often uses “root” as the default username, but it may be different. Check the app’s display.
  • Not having the server running. The SSH server must be actively running on Android before you try to connect.
  • Firewall blocking the port. Some Android devices have a firewall that blocks incoming connections. Ensure the SSH app is allowed through.

Tips

  • Use a static IP. Assign a static IP to your Android device in your router’s DHCP settings to avoid IP changes.
  • Set a strong password. Use a long, unique password for the SSH server, especially if you plan to access it over the internet.
  • Use key-based authentication. For better security, generate an SSH key pair on your computer and add the public key to the Android device’s authorized_keys file. This avoids password login.
  • Keep the app updated. Regularly update the SSH server app to get security patches.
  • Use SFTP for file management. Instead of SCP, you can use SFTP with a GUI client like FileZilla (Windows/macOS) to drag-and-drop files.

Troubleshooting

  • Connection refused or timeout. Check that the SSH server is running, the IP address is correct, and the port is right. Try pinging the Android device from your computer: ping 192.168.1.10. If ping fails, the devices are not on the same network.
  • Permission denied. This usually means the username or password is wrong. Re-enter the credentials from the SSH app. If using key-based auth, ensure the key is correctly placed.
  • Host key verification failed. This happens when the server’s key changes. Edit the ~/.ssh/known_hosts file on your computer and remove the line with your Android device’s IP, then try again.
  • Command not found. The Android shell is limited. Some commands like apt or yum are not available. Use basic shell commands like ls, cd, cp, mv, and rm.
  • No route to host. Check that both devices are on the same Wi-Fi network and that the router doesn’t have client isolation enabled.

Frequently Asked Questions

Is SSH on Android safe?

Yes, if you use a strong password or key-based authentication and only connect over trusted networks. Avoid using default passwords.

Can I access my Android from anywhere, not just home?

Yes, but you’ll need to set up port forwarding on your router and use your public IP address. This exposes your device to the internet, so use strong security measures.

What is the default port for SSH on Android?

Most SSH server apps use port 2222 by default, but it can be changed. Check the app’s settings.

Can I transfer files using SSH?

Yes, using SCP or SFTP. SFTP is more user-friendly and works with GUI clients like FileZilla.

Do I need root access on Android?

No, most SSH server apps work without root. However, root access gives you more control over the file system.

Why can’t I connect when my Android is on mobile data?

Mobile data often uses carrier NAT, making it impossible to connect directly. You’d need a VPN or a reverse SSH tunnel for remote access.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →