You run a Tor Hidden Service with sshd on one device. Knowing the .onion address, the correct port and having the corresponding private key on the other device (all of that not really subject to change), you can run the Tor daemon on it (for Android, you can use Termux) and connect with ssh, using torify nc %h%p as ProxyCommand.
How does Tor help
ssh
behind NAT?You run a Tor Hidden Service with
sshd
on one device. Knowing the .onion address, the correct port and having the corresponding private key on the other device (all of that not really subject to change), you can run the Tor daemon on it (for Android, you can use Termux) and connect withssh
, usingtorify nc %h %p
asProxyCommand
.