Linux 10 - Connect Linux and Android through Termux with SSH

By Sheldon L Published at 2019-11-10 Updated at 2019-11-12


Postinstallation setup of Termux in Adroid

pkg install root-repo
pkg update
pkg upgrade
pkg install htop nano

# install openssh
pkg install openssh
# take a screenshot about the dir of the `rsa` key
# '/' = '/data/data/com.termux/files/'
# may be '/data/data/com.termux/files/usr/etc/ssh/ssh_host_rsa_key.pub'

From Linux to Android

# copy public key
cat ~/.ssh/id_rsa.pub
# got user name
whoami
# say `username`

# got IP adress
ifconfig
# say 192.168.0.100

# open ssh server
sshd

# check which port the server is listening
logcat -s 'syslog'
# say '8022'

nano ~/.ssh/autorized_keys
# paste the public key in line here
ssh username@192.168.0.100 -p 8022

From Android to Linux

# install openssh-server
apt install openssh-server

# allow firewall
ufw allow ssh

# open ssh server
sshd

ssh <username>@<IPAdress> -p <port>