This is an article about running a secure home server by Cloudflare Zero Trust and Cloudflare Tunnel. You can connect from the public internet using Cloudflare Warp Client and the SSH server.
Prerequisites
- Cloudflare Account (Free tier)
- Docker
- SSH Server
Cloudflare Zero Trust
Cloudflare Zero Trust is a security architecture that replaces traditional network security perimeters with a more granular approach to access control. Instead of trusting everyone inside a network, Zero Trust assumes that no one is inherently trustworthy.
To create your Cloudflare Zero Trust Organization,
- Create a Cloudflare account.
- Go to https://one.dash.cloudflare.com/
- Choose a team name.
- Continuing the onboarding screen, you can choose “Zero Trust Free plan” for non subscription.
Cludflare Tunnel
To access the private IP of the server from the public internet without requiring Fixed IP, DNS, or NAT, you need to have a tunnel open for the server. This is work just like the VPN.
- Create a Cloudflare Tunnel.
- Choose Cloudflared tunnel type.
- Start the tunnel by Docker.
docker run cloudflare/cloudflared:latest tunnel --no-autoupdate run --token <replace-with-token>
You can also choose another way to run the tunnel, but I prefer Docker because we can remove it whenever we want.
Now the tunnel is running.
- Mapping the Private IP to the Tunnel
Put the CIDR and the description of the network.
[!CAUTION] Set your subnet mask carefully, all the IPs will be allowed to call from the internet.
To find the Private IP of the server, you can use ifconfig
the ip will start with 172.*.*.*
.
Running SSH Server
I will not write on this section because there are several ways to run the SSH server and expose the SSH port or Firewall.
For Ubuntu you can go to https://ubuntu.com/server/docs/openssh-server.
I would recommend creating a specific user for the SSH and generating the SSH key pair for it.
Cloudflare Warp
Cloudflare Warp is a client software to connect to the Cloudflare Zero Trust and Cloudflare Tunnel on a secure private network.
- Download and install Cloudflare Warp from https://one.one.one.one/
- Enter the organization name that you created in Cloudflare Zero Trust
- Connect and try to SSH by the Private IP of the server
It’s worked.