Beta Docs Sign inGet started

Tailscale

A private network of your own devices. Why SSH should only come over it. Tailnet Lock. The one rule a server needs. Key expiry.

Tailscale builds a private network of your own devices. Your laptop, your phone, your servers. That network is your tailnet.

Inside it, your devices see each other. Outside it, nobody sees them.

the internet: sees nothing on port 22
       ✗
┌──────────────── your tailnet ────────────────┐
│                                              │
│  laptop ◀── encrypted, direct ──▶ my-server  │
│  100.64.0.2                       100.64.0.5 │
│                                              │
└──────────────────────────────────────────────┘

Each device gets an address of its own, like 100.64.0.5, and a name, like my-server.tail0000.ts.net. The line between two devices is encrypted, with WireGuard. It works through home routers and office networks. The server needs no open port for it.

Why SSH only over it

SSH on public port 22 is the door every bot knocks on. Over Tailscale, that door is gone for the internet. Only your devices can reach it.

So moin moves SSH there. Right after the first deploy, it asks:

? Close public SSH, only Tailscale from now on? [Y/n]

Enter means yes. moin puts the server in your tailnet. It opens a new SSH session over Tailscale. Only when that works does port 22 close to the internet. Then it prints the new line for ~/.ssh/config:

  moin reaches my-server at my-server.tail0000.ts.net from now on.
  For ssh of your own, point my-server at the tailnet. In ~/.ssh/config, set:
    Host my-server
      HostName my-server.tail0000.ts.net

moin never edits that file itself. You change HostName, and ssh my-server goes over Tailscale from then on. moin itself needs no line: it connects to the server at its tailnet address from then on, under the name you gave it. SSH only over Tailscale

What you need

moin installs Tailscale on the server. It asks for an auth key, or prints a link to log the server in. Make a key in the Tailscale admin console: Settings, Keys, Generate auth key.

Tailnet Lock

Who controls your Tailscale account could add a device to your tailnet. That device could then reach your server’s SSH.

Tailnet Lock stops that. A new device joins only when one of your own devices signs it. Not even Tailscale can add one. Turn it on. It takes a few minutes, once.

Tags and the one rule

A tailnet has rules. They say which device may reach which. The default lets your own devices reach each other, so a fresh tailnet needs nothing.

Once you change the rules, a server needs exactly one: your laptop may reach it on port 22. Give servers a tag, and allow that tag. In the admin console, Access controls:

"tagOwners": {"tag:server": ["autogroup:admin"]},
"grants": [{"src": ["[email protected]"], "dst": ["tag:server"], "ip": ["tcp:22"]}]
  • tag:server is a name for all your servers.
  • src is you: your login, or your laptop’s tag, like tag:laptop.
  • tcp:22 is SSH, and nothing else.

Then give the server the tag: Machines, the server, the ⋯ menu, Edit ACL tags, tag:server. When the rules keep you out, moin prints this fix itself, with your names in it.

Key expiry

Each device in a tailnet has a key. By default, it expires after some months. Then the device has to log in again. For a server, that means: SSH stops.

Two ways out:

  • Tag the server. A tagged device’s key does not expire.
  • Turn key expiry off. Admin console, Machines, the server, the ⋯ menu, Disable key expiry.

Two weeks before a key expires, the server alerts, and moin shows it.

Locked out?

Your provider’s web console still works. Log in there and run:

/usr/local/bin/moin unlock

Port 22 opens to the internet again. The way back in