Configure Cloudflare Tunnel + cloudflared SSH

Cloudflare Tunnel + Cloudflared SSH to Home Server #

๐Ÿ  Part 1: On Your Home Server (Do this once) #

  1. Create the Tunnel:
  • Go to Cloudflare Zero Trust โ†’ Networks โ†’ Tunnels โ†’ Create a Tunnel.
    • Name it (e.g., home-ssh) and click Next.
  1. 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.
  1. 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.

  1. Install cloudflared on your laptop.
  2. 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
  1. Paste these exact 2 lines at the bottom of the file and save it:

Host yoursubdomain.example.com ProxyCommand cloudflared access ssh –hostname %h

  1. To Connect: Just type this single, standard command anytime you want to log in:

ssh [email protected]


Option B: The Manual Way (If you don’t want to change config files) #

Warning: Requires keeping two separate terminal windows open.

  1. 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

  1. Window 2 (The Connection): Open a brand new terminal window and jump into your server:

ssh username@localhost -p 2222