Logging In and Named Tunnels
Outcome: you understand the one credential
that unlocks every named-tunnel command,
you have seen the login handshake begin
for real, and you know exactly which
error stands guard until it completes.
Named tunnels (chapter 1) live in a
Cloudflare account. cloudflared proves it
may act for that account with cert.pem,
and getting one is a short ceremony
shared between the terminal and a
browser.
The login handshake
cloudflared tunnel login
The lab ran it and kept the opening
(transcript
cloudflared-lab/transcripts/t08-login.txt):
$ cloudflared tunnel login
A browser window should have opened at the following URL:
https://dash.cloudflare.com/argotunnel?aud=&callback=https%3A%2F%2Flogin.cloudflareaccess.org%2F...
cloudflared prints a one-time address on
Cloudflare's dashboard and then waits. In
the browser you sign in (creating the
free account first, if this is your first
visit), and Cloudflare asks which one
domain the certificate should be able to
manage tunnels and DNS for. You pick it,
approve, and the browser hands the result
back to the waiting cloudflared, which
writes ~/.cloudflared/cert.pem and
exits.
The lab stopped the command after eight
seconds, at the waiting stage: a sandbox
has no browser session to sign in with,
so the ceremony's second half is
documented-only in this guide, and no
cert.pem was written. That is the
honest state of chapter 5's evidence —
the door and the keyhole are real, the
turning of the key is described.
Two facts about cert.pem deserve the
emphasis chapter 2 promised:
- It is scoped but powerful. It acts for the zones you authorised at login, and within them it can create and delete tunnels and rewrite DNS records — the keys to where your names point. Treat the file like a password: never commit it, never copy it to a machine you do not control, and if it leaks, the remedy is to revoke it from the dashboard and log in again.
- It is not the tunnel's running
credential. Day to day,
tunnel runuses the per-tunnel credentials file.cert.pemis needed to manage — create, list, route, delete — and a machine that only ever runs one tunnel can be given just that tunnel's file.
The guard at every door
Until login completes, every management
command stops at the same guard, and the
lab collected the set (transcript
cloudflared-lab/transcripts/t06-named-tunnel-no-account.txt).
For tunnel list:
ERR Cannot determine default origin certificate path. No file cert.pem in [~/.cloudflared ~/.cloudflare-warp ~/cloudflare-warp /etc/cloudflared /usr/local/etc/cloudflared]. You need to specify the origin certificate path by specifying the origincert option in the configuration file, or set TUNNEL_ORIGIN_CERT environment variable
Error locating origin cert: client didn't specify origincert path
tunnel create demo-tunnel and tunnel
run demo-tunnel fail with the same
explanation in slightly different
wrapping. Read the message once and it
never mystifies again: no cert.pem,
searched in five named places, full stop.
Chapter 12 lists it as the most common
named-tunnel error there is, because
every reader who skips login meets it
within a minute.
Creating the tunnel (documented)
With cert.pem in place, the remaining
steps are short, and are documented here
rather than run — the account they act on
is the reader's, not the lab's:
cloudflared tunnel create photos
cloudflared tunnel list
create registers a tunnel named
photos in the account, prints its UUID,
and writes the credentials file
~/.cloudflared/<uuid>.json. list
shows the account's tunnels, their IDs,
and whether a connector is currently
running for each. The tunnel now exists
— chapter 6 gives it its instructions,
and chapter 7 puts its name in DNS and
sets it running. cloudflared tunnel
info <name> reports a running tunnel's
connectors in more detail, and tunnel
delete <name> removes the object (and
refuses, at first, while connectors are
attached — you stop them, then delete,
then remove the DNS record, in that
order).
The token alternative
Chapter 2 mentioned the dashboard style:
create the tunnel in the Zero Trust
dashboard instead, and the dashboard
hands you a long token;
cloudflared tunnel run --token <token>
runs that tunnel with its configuration
read from the dashboard rather than a
local file. The token is a full-strength
credential for that tunnel — same
handling rules as the credentials file.
This guide stays with the local style,
where chapters 6's file can be validated
and questioned offline; the token route
is documented-only here and loses none of
its usefulness for being described
briefly.