Skip to content

Instantly share code, notes, and snippets.

@mitanshu7
Last active July 30, 2025 16:39
Show Gist options
  • Save mitanshu7/2beb5c56d0e86d88fb7c396b901f9ca6 to your computer and use it in GitHub Desktop.
Save mitanshu7/2beb5c56d0e86d88fb7c396b901f9ca6 to your computer and use it in GitHub Desktop.

After setting up Cloudflared on Termux, we can now SSH into the phone that has Termux installed.

Cloudflare setup

  1. Create a Public Hostname, ssh.example.com, with the following properties:

    a. Service type: SSH

    b. URL: 127.0.0.1:8022

  2. In Cloudflared Access, go to Applications and create a new one, with the following properties:

    a. Application name (can be anything): ssh

    b. Public host name: ssh.example.com

    c. Add access policy allow your own email.

    d. Browser rendering settings: SSH

Termux Setup

  1. Install openssh:
pkg upgrade
pkg install openssh
  1. Start server by issuing:
sshd
  1. Use the service via:
sv up sshd
sv-enable sshd
  1. If you need to stop sshd, just kill it's process:
pkill sshd
  1. Know your username via:
whoami

Password access

Create a new password with passwd

$ passwd
New password:
Retype new password:
New password was successfully set.

Pubkey authentication

From your PC, copy the public key, if already generated, else see Generating a new SSH key

For e.g.

cat .ssh/id_ed25519.pub

and paste it in Termux:

nano .ssh/authorized_keys

Browser

  1. Visit ssh.example.com

  2. Access application via your email

  3. Enter your username, of the type: u0_a264

  4. Either type in your password or paste your private key

  5. Profit!

References

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

https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/use-cases/ssh/ssh-browser-rendering/

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