Cloudflare Tunnel + Cloudflared SSH to Home Server #
๐ Part 1: On Your Home Server (Do this once) #
- Create the Tunnel:
- Go to Cloudflare Zero Trust โ Networks โ Tunnels โ Create a Tunnel.
- Name it (e.g., home-ssh) and click Next.
- Install the Agent:
- Copy the exact command Cloudflare gives you for your server’s OS.
- Paste it into your home server’s terminal and run it.
- Wait until the website says “Connected” (Green), then click Next.
- Route the Traffic:
- Subdomain: your-subdomain (e.g. myssh)
- Domain: example.com
- Type: Published application
- URL: localhost:22
- Click Save Tunnel.
๐ป Part 2: On Your Laptop (Every time you are away from home) #
Option A: The One-Line Way #
Set this up once, and you will never have to remember annoying Cloudflare commands again.
- Install
cloudflaredon your laptop. - Open your laptop’s SSH config file.
- On Mac/Linux, open terminal and type: nano ~/.ssh/config
- On Windows, open the file at: C:\Users\YourName.ssh\config
- Paste these exact 2 lines at the bottom of the file and save it:
Host yoursubdomain.example.com ProxyCommand cloudflared access ssh –hostname %h
- To Connect: Just type this single, standard command anytime you want to log in:
Option B: The Manual Way (If you don’t want to change config files) #
Warning: Requires keeping two separate terminal windows open.
- Window 1 (The Bridge): Run this command to open the tunnel gate (leave this window open!):
cloudflared access ssh –hostname yoursubdomain.example.com –url localhost:2222
- Window 2 (The Connection): Open a brand new terminal window and jump into your server:
ssh username@localhost -p 2222