Setting up SSH Tunnel using Self-hosted Cloudflare Zero Trust
This tutorial will guide you through the process of setting up an SSH tunnel using self-hosted Cloudflare Zero Trust. This allows you to securely access your server from anywhere with an internet connection.
Step 1: Buy a Domain
First, you need to purchase a domain name. For this example, we'll use Namecheap.
Step 2: Add Domain to Cloudflare
Next, add your domain to Cloudflare.
Step 3: Choose Your Plan
Step 4: Update Nameservers at Namecheap
Update your domain's nameservers at Namecheap to point to Cloudflare.
Step 5: Set up Self-hosted Zero Trust
Set up self-hosted Zero Trust on Cloudflare.
Step 6: Create Policy
Create a policy to control access to your application.
Step 7: Set up SSH Application
Set up the SSH application in Cloudflare Zero Trust.
Recommended by LinkedIn
Note: Free Plan SSH Issue
The Cloudflare Free Plan may not work with SSH on subdomain. It may cause the error like:
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
So I recommend leave the subdomain blank in the application configuration.
Step 8: Set up Tunnel
Set up the Cloudflare Tunnel.
Step 9: Configure Public Hostname for SSH Tunnel
Configure the public hostname for the SSH tunnel.
Note: Open SSH server
Please note that the SSH server must be open on the machine. Use OpenSSH server to open SSH on port 22.
In case you want to open SSH on another port, please also specify the `ssh://<your_domain>:<port>` in the above Public Hostname configuration.
Step 10: Set up Access at Client
Set up access at the client machine.
cloudflared access ssh-config --hostname yourdomain.com
Step 11: Connect SSH
Connect to your server using SSH.
ssh user@yourdomain.com
You have now successfully set up an SSH tunnel using self-hosted Cloudflare Zero Trust!