How to SSH into an Oracle Cloud VPS from Your Mac Using Cloudflare Tunnel
- Get link
- X
- Other Apps
How to SSH into an Oracle Cloud VPS from Your Mac Using Cloudflare Tunnel
In the previous tutorials, we configured a free domain with Cloudflare, connected it to an Oracle Cloud VPS, and published a website using Cloudflare Tunnel.
Now let's take it one step further.
Wouldn't it be convenient to SSH directly into your Oracle Cloud VPS from your Mac, without opening port 22 to the public Internet or launching Oracle Cloud Shell every time?
That's exactly what we'll accomplish in this tutorial.
1. What We Want to Achieve
Our goal is to run this command directly from the Mac terminal:
ssh ociAnd connect to our Oracle Cloud VPS.
Our VPS has:
Oracle Linux 9
ARM64 architecture
2 OCPUs and 12 GB RAM
A private IP address only
No public IP address
We will reuse the Cloudflare Tunnel configured in the previous tutorial.
2. Understand the Architecture
The connection will look like this:
Mac
|
| ssh oci
|
| SSH + cloudflared
v
Cloudflare Access
|
v
Cloudflare Network
|
v
Cloudflare Tunnel
|
v
OCI VPS (private network)
|
v
sshd (localhost:22)There are three separate components involved:
Cloudflare Tunnel provides a secure outbound connection from our VPS to Cloudflare.
Cloudflare Access optionally authenticates users before allowing access to the SSH application.
SSH keys authenticate the Linux user on the VPS.
The important point is that our VPS does not need a public IP address, and we do not need to expose port 22 publicly.
3. Configure SSH on the Oracle Cloud VPS
First, connect to your VPS using your existing method, such as Oracle Cloud Shell.
Check whether the SSH service is running:
sudo systemctl status sshdIf it isn't running, enable and start it:
sudo systemctl enable --now sshdCheck that SSH is listening on port 22:
sudo ss -lntp | grep ':22'Make sure the service is accessible locally through port 22.
4. Add an SSH Application to Cloudflare Tunnel
Open the Cloudflare dashboard.
Navigate to:
Zero Trust → Networks → Connectors → Cloudflare Tunnels
Select the existing Tunnel that your OCI VPS is already using.
Open its published application routes and add a new route.
Configure it as follows:
| Setting | Value |
|---|---|
| Subdomain | ssh |
| Domain | qzlapp.us.ci |
| Path | Leave empty |
| Service Type | SSH |
| Service URL | ssh://localhost:22 |
The resulting hostname is:
ssh.qzlapp.us.ciNote: Depending on the Cloudflare dashboard version, SSH might not appear as a separate service type. The Service URL field accepts the ssh:// scheme directly.
Save the route.
Cloudflare will create the corresponding DNS record pointing to your Tunnel.
You do not need to create another Tunnel. Multiple applications can share the same Tunnel.
5. (Recommended) Configure Cloudflare Access
For additional protection, create a self-hosted application in Cloudflare Access.
Use:
ssh.qzlapp.us.ciThen create an Allow policy for your own email address.
This ensures that only authorized users can access the SSH application through Cloudflare Access.
Remember that Cloudflare Access and Linux SSH authentication are separate layers.
6. Install cloudflared on Your Mac
Now switch to your Mac terminal.
If you use Homebrew, install the Cloudflare client:
brew install cloudflaredVerify the installation:
cloudflared --versionCheck its location:
which cloudflaredOn an Apple Silicon Mac, the usual result is:
/opt/homebrew/bin/cloudflared7. Configure Your SSH Key
Make sure you have your private SSH key available on your Mac.
For example:
~/.ssh/ssh-key-2026-11-05.keySSH requires private keys to have restrictive permissions:
chmod 400 ~/.ssh/ssh-key-2026-11-05.keyIf you haven't configured SSH public-key authentication on your VPS yet, add the corresponding public key to the Linux user's ~/.ssh/authorized_keys.
8. Configure SSH ProxyCommand
This is the most important step.
Open your SSH configuration file on your Mac:
nano ~/.ssh/configAdd:
Host oci
HostName ssh.qzlapp.us.ci
User opc
ProxyCommand /opt/homebrew/bin/cloudflared access ssh --hostname %h
IdentityFile ~/.ssh/ssh-key-2026-11-05.key
IdentitiesOnly yes
ServerAliveInterval 30Let's understand the important line:
ProxyCommand /opt/homebrew/bin/cloudflared access ssh --hostname %hNormally, SSH attempts to establish a direct TCP connection to the SSH server.
However, our VPS does not have a public IP address.
ProxyCommand tells SSH to launch an external program to establish the connection instead.
Here is what each part means:
| Part | Explanation |
|---|---|
ProxyCommand | Use an external program as the connection transport |
/opt/homebrew/bin/cloudflared | The Cloudflare client installed on your Mac |
access ssh | Start the Cloudflare SSH connection process |
--hostname %h | Pass the SSH hostname to cloudflared |
The %h is an SSH configuration placeholder. SSH replaces it with the value of HostName.
In our example, it becomes:
cloudflared access ssh --hostname ssh.qzlapp.us.ciThis allows SSH to use Cloudflare Tunnel as its network path while keeping the normal SSH authentication workflow.
9. Connect!
Now comes the fun part.
Simply run:
ssh ociIf Cloudflare Access is configured, you may need to authenticate through your browser first.
After that, SSH uses your private key to authenticate the Linux user.
You should see something similar to:
Last login: Fri Nov 6 09:02:47 2026
[opc@oci-qzl-vnic-1 ~]$Congratulations! You are now connected directly from your Mac to your private Oracle Cloud VPS.
No Oracle Cloud Shell required!
10. Enjoy Your Normal SSH Workflow
The best part is that you can continue using familiar SSH commands.
Run a remote command:
ssh oci "hostname"Copy a file to the VPS:
scp file.txt oci:~/Copy a file from the VPS:
scp oci:~/file.txt .Forward a remote port to your Mac:
ssh -L 8080:localhost:8000 ociThen open:
http://localhost:8080This is particularly useful when developing applications on your VPS.
Conclusion
We have successfully connected a private Oracle Cloud VPS directly from a Mac using Cloudflare Tunnel.
Our setup now provides:
No public IP address required
No publicly exposed SSH port
No need to open inbound port 22 in OCI
Cloudflare Access authentication (when configured)
Normal SSH key authentication
Familiar SSH, SCP, and port-forwarding commands
A private VPS can still be very convenient to manage remotely.
All we need is an outbound Cloudflare Tunnel and the cloudflared client on our Mac.
❤️ 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