Skip to main content

SSH for Android

SSH on Android

Step by step

  • Install F-Droid app from Internet
  • Install Termux app from F-Droid
  • Install openssh binary from Termux
    • Open a Termux window
    • Run the following
      pkg upgrade
      pkg install openssh
      

Usage

  • Start the SSH server
    (Default SSH port in Termux is 8022)
    sshd
    
  • Stop the SSH server
    pkill sshd
    

Setup public key authentication

  • Copy public key Use scrpy to copy file locally
    ssh-copy-id -p 8022 -i {id_rsa file} {android ip address}
    
  • Disable password auth in sshd configuration file
    Set PasswordAuthenticationto no in $PREFIX/etc/ssh/sshd_config
    sed -Ei"_ori" 's/[#]?PasswordAuthentication yes|PasswordAuthentication no|g' $PREFIX/etc/ssh/sshd_config
    

Resources

https://github.com/termux
https://wiki.termux.com/wiki/Remote_Access
https://wiki.termux.com/wiki/Main_Page