brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: a file: auth key keeps your Tailscale key out of shell history

Network and access
~/tips/tip-tailscale-auth-key-from-file

sudo tailscale up --auth-key=file:/root/ts-authkey

Pass a Tailscale auth key from a protected file instead of typing it on the command line.

Auth keys let a server join your tailnet without a browser login. Typing one on the command line leaves it in your shell history and in the process list. The CLI can read it from a file instead.

Save the key in a file only root can read, then point to it with the file: prefix:

sudo install -m 600 /dev/null /root/ts-authkey
sudo nano /root/ts-authkey
sudo tailscale up --auth-key=file:/root/ts-authkey

The help text says that when the value begins with file:, it is read as a path to a file holding the key.

When you create the key in the admin console, think about the options. A one-off key works once; a reusable one joins many machines. Ephemeral removes the device when it goes offline, which suits containers and CI runners. Tags assign the device to a tag right away. And a key expires after at most 90 days, so a script that runs much later needs a new one.

Once the device has joined, the key is no longer needed on it. I’d delete the file afterwards, because a reusable key lying around on a server can add any machine to your tailnet.

Further reading: Auth keys, tailscale up command

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link