How to SSH into an Oracle Cloud VPS from Android Using Termux and Cloudflare Tunnel
- Get link
- X
- Other Apps
How to SSH into an Oracle Cloud VPS from Android Using Termux and Cloudflare Tunnel
You don't need a public IP address to SSH into your Oracle Cloud VPS from your Android phone.
With Termux, OpenSSH, Cloudflare Tunnel, and Cloudflare Access, you can securely connect to your Oracle Cloud VPS directly from your Android device.
In this tutorial, I'll show you how to configure everything step by step.
1. Architecture
Here is how the connection works:
Android Phone
|
v
Termux + OpenSSH
|
v
cloudflared (ProxyCommand)
|
v
Cloudflare Access
|
v
Cloudflare Tunnel
|
v
Oracle Cloud VPS
|
v
localhost:22 (SSH)The VPS does not need a public IP address or an exposed SSH port.
Cloudflare Access handles authentication, while SSH public-key authentication verifies the user on the VPS.
2. Prerequisites
Before starting, make sure you have:
An Oracle Cloud VPS running Linux.
A Cloudflare Tunnel already connected to your VPS.
A Cloudflare Public Hostname configured for SSH.
A Cloudflare Access application protecting that hostname.
SSH access to your VPS from another computer (for example, your Mac).
For this tutorial, I'll use the following example configuration:
| Setting | Value |
|---|---|
| VPS provider | Oracle Cloud |
| VPS username | opc |
| SSH port | 22 |
| SSH hostname | ssh.qzlapp.us.ci |
| Android terminal | Termux |
Replace the hostname with your own domain.
3. Install Termux
Install Termux on your Android phone.
I recommend downloading it from F-Droid or the official Termux GitHub releases.
Open Termux and update the packages:
pkg update && pkg upgrade -yInstall OpenSSH and cloudflared:
pkg install openssh cloudflared -yVerify the installation:
ssh -V
cloudflared --version4. Generate an SSH Key on Android
Instead of copying your Mac's private SSH key to your phone, generate a separate key pair.
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t ed25519 \
-f ~/.ssh/oci_android \
-C "android-termux"The -C option adds a comment to identify the key. It is not the VPS username.
For example:
android-termuxis the key comment.opcis the Linux username on Oracle Cloud.
You now have two files:
~/.ssh/oci_android
~/.ssh/oci_android.pubThe first file is your private key. Never share it.
The second file is your public key.
Display the public key:
cat ~/.ssh/oci_android.pubCopy the entire output.
5. Add the Android Public Key to Oracle Cloud VPS
From your Mac or another computer that already has SSH access to the VPS, connect to your server:
ssh ociOpen the authorized keys file:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keysPaste the Android public key on a new line.
Save the file and update its permissions:
chmod 600 ~/.ssh/authorized_keysYour VPS now recognizes the SSH key generated by your Android phone.
You can keep your Mac's existing SSH key. Both devices can have separate keys.
6. Configure SSH on Android
Back in Termux, create or edit your SSH configuration:
nano ~/.ssh/configAdd the following configuration:
Host oci
HostName ssh.qzlapp.us.ci
User opc
ProxyCommand cloudflared access ssh --hostname %h
IdentityFile ~/.ssh/oci_android
IdentitiesOnly yesSave the file and set the permissions:
chmod 600 ~/.ssh/config
chmod 600 ~/.ssh/oci_androidLet's understand the important settings.
Host oci
This is a shortcut. Instead of typing the full hostname, you can simply run:
ssh ociUser opc
This is the Linux username on Oracle Cloud.
ProxyCommand
ProxyCommand cloudflared access ssh --hostname %hThis is the most important part.
OpenSSH normally connects directly to the SSH server. However, our VPS does not expose SSH directly to the public internet.
The ProxyCommand tells SSH to start cloudflared and use it as a proxy.
The %h variable represents the hostname defined in HostName.
Cloudflared establishes the connection through Cloudflare Access and the Cloudflare Tunnel.
Notice that we don't need to specify a full executable path on Android. Termux can find cloudflared through its PATH.
7. Authenticate with Cloudflare Access
Before connecting, authenticate through Cloudflare Access:
cloudflared access login https://ssh.qzlapp.us.ciFollow the authentication instructions.
If Termux does not automatically open your browser, copy the authentication URL and open it in Chrome.
Sign in using an email address permitted by your Cloudflare Access policy.
Make sure the Cloudflare Access application protects the SSH hostname.
8. Connect to Your Oracle VPS
Now the fun part!
Simply execute:
ssh ociYou should be connected to your Oracle Linux VPS.
For example:
[opc@oci-vps ~]$That's it!
You can now manage your Oracle Cloud VPS directly from your Android phone without a public IP address.
9. Troubleshooting
Connection closed by UNKNOWN port 65535
If you see:
Connection closed by UNKNOWN port 65535Check the following:
Is cloudflared installed correctly?
Is the Cloudflare Access application configured for your SSH hostname?
Have you completed Cloudflare Access authentication?
Is the Cloudflare Tunnel running?
Does the VPS SSH service work locally?
You can enable SSH debugging:
ssh -vvv ociAlso check:
which cloudflared
cloudflared --versionPermission denied (publickey)
Check that:
You copied the correct public key to the VPS.
The VPS username is correct (
opcin this example).The private key path in
~/.ssh/configis correct.File permissions are correct.
Conclusion
Combining Termux, OpenSSH, and Cloudflare Tunnel gives you a convenient way to manage an Oracle Cloud VPS from your Android phone.
My favorite part is that the VPS does not need a public IP address.
The same approach also works on macOS and Linux. Once configured, connecting is as simple as:
ssh ociNo need to remember complicated commands or expose SSH directly to the internet.
Happy hacking!
❤️ Support This Blog
If this post helped you, you can support my writing with a small donation. Thank you for reading.
- Get link
- X
- Other Apps

Comments
Post a Comment