Skip to content

Team access over Tailscale ​

If your team already uses Tailscale (or headscale), the Gate can be reachable only inside the tailnet, and a Member's tailnet identity becomes the credential. There is no public SSH for the Gate, no per-Member key to manage and no Access Token. Everything else in Sharing one App with a team still applies: the same verbs, the same deploy policy, the same members.yml grants.

There are two ways to do it:

  • tsnet Gate (--network tsnet, recommended, and the default for a first yoho access install on a Server with systemd). The Gate is its own tailnet node. The Server needs no tailscaled and no sshd change, and Members need no SSH key and no known_hosts. See ADR 0023.
  • OpenSSH tailnet Gate (--network tailscale). OpenSSH serves the yoho-gate user only to tailnet peers, through the Server's own tailscaled. See below and ADR 0022.

How it works ​

  • yoho access install --network tsnet installs /usr/local/bin/yoho and a root systemd unit, yoho-gate-tsnet.service, that runs yoho gate serve. That process embeds a Tailscale node (tailscale.com/tsnet) named yoho-gate-<server>, tagged tag:yoho-gate, with its state in /var/lib/yoho-gate-tsnet (root, 0700).
  • The node listens on TCP port 7022 on its own tailnet addresses only. Nothing listens on the Server's own interfaces, and sshd, the firewall and any tailscaled on the Server are not touched.
  • For each connection yoho gate serve asks its node who the peer is (WhoIs, from the node's map of the tailnet). It refuses the Gate's own node and a peer with neither a user nor tags, then starts one Gate process for the connection, with the identity handed over on a pipe. Arguments and environment variables cannot name an identity.
  • The identity selects one Member: a person by their tailnet login (--tailscale alice@example.com), a tagged node such as a CI runner by its tag (--tailscale-tag tag:yoho-ci). No match, or more than one, is refused.
  • audit.log records "via": "tsnet", the Tailscale login, node name, node ID and tags, and the client's tailnet address of every request.
  • At most 32 connections are served at once; more get "the Gate is busy".

Operator: set up once ​

  1. Let Members and CI reach the Gate's tag on port 7022 in the tailnet policy file. This is a plain network grant, not an ssh rule:

    json
    "tagOwners": {
      "tag:yoho-gate": ["autogroup:admin"],
      "tag:yoho-ci":   ["autogroup:admin"]
    },
    "grants": [
      {"src": ["alice@example.com", "bob@example.com", "tag:yoho-ci"], "dst": ["tag:yoho-gate"], "ip": ["tcp:7022"]}
    ]

    Members connect from a separate tailnet device of their own, yoho-member-<host> (Yoho's embedded node, owned by the Member's login), and CI from an ephemeral tag:yoho-ci node, so allow tag:yoho-gate:7022 from the Members' users and from tag:yoho-ci. With the older acls syntax: {"action": "accept", "src": [...], "dst": ["tag:yoho-gate:7022"]}. tagOwners must let the auth key (or the person who logs the node in) own tag:yoho-gate; otherwise the node joins without its tag, belongs to that person, and the grant cannot name it.

  2. Install the Gate. Either give it an auth key, or let install print a login URL:

    sh
    # with an auth key: create a reusable or one-off key tagged tag:yoho-gate in the admin console
    yoho access install --network tsnet --tailscale-auth-key-file ./gate.authkey -d production
    
    # without one: install prints a login URL once and waits up to 10 minutes
    yoho access install --network tsnet -d production

    --network tsnet is the default on a first install, so plain yoho access install does the same on a new Server with systemd. The key is read from the file, copied to the Server over stdin into /etc/yoho/gate-tsnet.authkey (root, 0600), and removed by the Gate once the node is up. It never goes into argv or the environment, and Yoho masks tskey-… in its output.

  3. Push the settings and add Members:

    sh
    yoho access secrets push -d production
    yoho access add alice --verbs all --tailscale alice@example.com -d production
    yoho access add ci --verbs deploy,releases,rollback --tailscale-tag tag:yoho-ci -d production
    yoho access ls -d production       # MEMBER  VERBS  TAILSCALE  KEYS, then the Gate network
    yoho doctor -d production

Install flags for the node:

FlagDefaultMeaning
--tsnet-hostname NAMEgate_tsnet_hostname, else the recorded one, else yoho-gate-<server>The node's tailnet name.
--tsnet-port Nthe recorded one, else 7022The tailnet port the Gate listens on.
--tailscale-advertise-tag TAGgate_tsnet_tag, else the recorded one, else tag:yoho-gateThe node's tag. It cannot be empty. Members' gate_tsnet_tag must match it.
--tailscale-control-url URLthe recorded one, else Tailscale'sCoordination server, such as headscale.
--tailscale-auth-key-file PATHnoneAuth key for the node's first login (a global flag).
--tsnet-login-timeout D10mHow long install waits for the node to log in.
--purge-tsnet-stateoffRemove the node's state: log it in afresh, or clean up when switching away from tsnet.

The unit reads its own settings from /etc/yoho/gate-tsnet.json (root, 0600: the Yoho root, hostname, port, tag, control URL). Install switches /etc/yoho/gate.json to "network": "tsnet" only after the node is logged in, carries its tag and listens; until then the current Gate keeps serving, and a failed or interrupted install leaves gate.json as it was. yoho gate serve refuses every connection while its node does not carry the configured tag, and refuses to start through sudo. If the node already has state, a new auth key is not used; pass --purge-tsnet-state to log the node in again. If install stops waiting for the login, the unit keeps running and waiting, and the next yoho access install picks up where it is.

Tagged nodes have key expiry disabled by default. If yours does not, disable it in the admin console: yoho doctor warns, and an expired node key locks every Member out.

Member: connect over the tailnet ​

The shared Yoho file marks the Destination scoped and tsnet:

yaml
destinations:
  production:
    servers: [main]
    access: scoped
    gate_network: tsnet
    # gate_tsnet_hostname: yoho-gate-main   # default: yoho-gate-<server>
    # gate_address: yoho-gate-main.tail1234.ts.net:7022   # only if MagicDNS is off or the port differs

Then use the usual commands:

sh
yoho deploy -d production
yoho app logs web -f -d production

The CLI connects to <gate_address, else gate_tsnet_hostname, else yoho-gate-<server>>:7022 with a plain TCP connection over the tailnet:

  • The CLI always uses its own embedded tailnet node, yoho-member-<host>: a separate device on the tailnet, like Rex clients. A tailscaled on the machine is not used, and the connection never goes through the host's routing table, only through the node's own network stack.
  • It finds the Gate in the node's peer list: the one node with that name (or address) that carries the Gate tag, gate_tsnet_tag (default tag:yoho-gate). It dials that node's tailnet address, so a DNS answer from elsewhere never receives a request, and it refuses an untagged node with the Gate's name. Set gate_tsnet_tag when the operator used another --tailscale-advertise-tag.
  • Before and after connecting, and before it sends anything, the node's WhoIs must say the address belongs to that Gate node (same node ID) and that it carries the Gate tag. Anything else is refused. An IP literal in gate_address is dialed as given.
  • The node keeps its state in ~/.config/yoho/tsnet (on macOS, ~/Library/Application Support/yoho/tsnet), mode 0700. It logs in with TS_AUTHKEY, else --tailscale-auth-key-file, else it prints a login URL once and waits up to 5 minutes. After the first login the node keeps its state.
  • For headscale, set gate_tsnet_control_url on the Destination, or TS_CONTROL_URL (which wins).

No SSH key, no known_hosts and no Cloudflare Tunnel are involved. If the connection drops during a deploy, the rollout finishes on the Server, and the CLI reconnects and waits for the outcome.

Deploy from GitHub Actions ​

CI joins the tailnet as an ephemeral node inside the yoho process. No SSH key, no known_hosts line and no Access Token are stored, only a Tailscale credential.

  1. In the Tailscale admin console, create an OAuth client with the auth_keys write scope limited to tag:yoho-ci, and store its secret (tskey-client-…) as the repository secret TS_OAUTH_SECRET. Or create an ephemeral, tagged (tag:yoho-ci) auth key and store that instead. If device approval is on, add ?preauthorized=true to the OAuth client secret.
  2. Add the Member: yoho access add ci --verbs deploy,releases,rollback --tailscale-tag tag:yoho-ci -d production.
  3. Use a workflow like this one:
yaml
# .github/workflows/deploy.yml
name: deploy
on:
  push:
    tags: ["v*"]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Install yoho
        run: curl -fsSL https://yohobuild.com/install.sh | sh
      - name: Deploy through the Gate
        env:
          TS_AUTHKEY: ${{ secrets.TS_OAUTH_SECRET }}   # OAuth client secret, or an ephemeral tagged auth key
          YOHO_ACCESS: scoped                         # or access: scoped in the Yoho file
        run: |
          yoho releases -d production
          yoho deploy -d production

With TS_AUTHKEY set, the CLI's node is ephemeral, keeps its state in memory, and is named yoho-ci. With an OAuth client secret it advertises tag:yoho-ci, or the tags in YOHO_TSNET_TAGS (comma-separated). The node disappears when the job ends. The audit log shows the tag and the node name for every request.

Switching networks ​

yoho access install keeps the network recorded in /etc/yoho/gate.json until you pass --network or set gate_network on the Destination. Existing Gates are never switched by an upgrade.

  • To tsnet (--network tsnet): install warns about Members without a Tailscale selector. It removes the tailnet sshd drop-in (when the Gate was tailscale), the sudoers rule and /etc/yoho/gate-keys. It keeps the yoho-gate user and its authorized_keys, so switching back to public keeps the Members' keys.
  • Away from tsnet (--network public or --network tailscale): install warns about Members left without a credential, then stops, disables and removes the unit and the auth key file. The node's state in /var/lib/yoho-gate-tsnet stays, so switching back reuses the same node, unless you pass --purge-tsnet-state.

A first install (no gate.json) on a Server with systemd picks tsnet. Without systemd it picks tailscale when the Server is logged in to a tailnet with Tailscale SSH off, else public. A retry after a failed first install keeps the network that run chose.

Doctor ​

On a tsnet Gate, yoho doctor checks:

  • yoho-gate-tsnet.service is active and enabled, and its unit file is this version's;
  • /var/lib/yoho-gate-tsnet is root-owned with mode 0700 (it holds the node's private keys);
  • the node is logged in (if not, the hint is the login URL) and carries its tag;
  • the node key has not expired (error), does not expire within 14 days (warning), and has expiry disabled when the node is tagged (warning);
  • the auth key file is gone once the node is up;
  • the node's status file is fresh, and the node listens on the configured port.

It cannot read the tailnet policy and says so: test the grant with yoho releases from a Member's device.

What to know ​

  • No sshd, no tailscaled on the Server. The OpenSSH caveats below (Tailscale SSH, AllowUsers, listen addresses, OpenSSH versions) do not apply. A tsnet Gate has no sudoers rule, so a Tailscale SSH shell as yoho-gate cannot reach it either.
  • Restarts. The unit restarts on failure. Restarting or upgrading it stops only yoho gate serve: requests in progress end when their connection drops, and a detached rollout runs to completion.
  • Logs to Tailscale. Like tailscaled, the embedded node uploads its logs to Tailscale's log service by default.
  • headscale. Install with --tailscale-control-url https://headscale.example.com; Members set gate_tsnet_control_url to the same URL on the Destination (or TS_CONTROL_URL, which wins).
  • Builds without tsnet. A yoho built with -tags notsnet leaves Tailscale's code out; every tsnet call then fails with "built without tsnet". Release builds include it.

Alternative: OpenSSH tailnet Gate ​

Use --network tailscale when you want the Gate served by the Server's own sshd and tailscaled instead of a separate node, or on a Server without systemd.

How it works ​

  • OpenSSH serves yoho-gate only when a tailnet peer connects to one of the Server's tailnet addresses. Then a Match block in /etc/ssh/sshd_config.d/yoho-gate.conf forces the Gate (sudo -n /usr/local/bin/yoho gate --via tailscale). It turns off TTYs, TCP, socket, X11 and agent forwarding, tunnels and user rc files. From any other address, sshd denies yoho-gate. Operator SSH is not affected.
  • sshd accepts any SSH key the Member offers, through a root-owned AuthorizedKeysCommand (/etc/yoho/gate-keys) that echoes the key back restricted to the Gate. No key is stored or shared; the key only completes the SSH handshake.
  • The Gate reads SSH_CONNECTION and checks that the client is a tailnet address (100.64.0.0/10 or fd7a:115c:a1e0::/48), the connection arrived on the Server's own tailnet address (tailscale status), the client is not the Server itself, and Tailscale SSH is off (tailscale debug prefs). Then it asks tailscaled who the client is (tailscale whois). It refuses when tailscaled cannot answer.
  • The identity selects one Member: a person by their tailnet login (--tailscale alice@example.com), a tagged node such as a CI runner by its tag (--tailscale-tag tag:yoho-ci). No match, or more than one, is refused.
  • audit.log records the Tailscale login, node name, node ID and tags of every request.

Operator: set up once ​

  1. Put the Server on the tailnet with a tag, without Tailscale SSH. Tailscale SSH (--ssh) would take port 22 on the tailnet address, so OpenSSH would never see Members:

    sh
    # on the Server
    tailscale up --advertise-tags=tag:yoho-server
    tailscale set --ssh=false      # if Tailscale SSH was on

    Tailscale SSH must stay off on a Server with a tailnet Gate: it would answer port 22 for yoho-gate with a shell instead of the Gate. yoho access install, yoho doctor and the Gate itself check tailscale debug prefs and refuse while it is on or cannot be read.

  2. Let Members reach the Server's SSH port in the tailnet policy file. This is a plain network grant, not an ssh rule:

    json
    "tagOwners": {
      "tag:yoho-server": ["autogroup:admin"],
      "tag:yoho-ci":     ["autogroup:admin"]
    },
    "grants": [
      {"src": ["alice@example.com", "bob@example.com", "tag:yoho-ci"], "dst": ["tag:yoho-server"], "ip": ["tcp:22"]}
    ]

    With the older acls syntax: {"action": "accept", "src": [...], "dst": ["tag:yoho-server:22"]}.

  3. Install the Gate:

    sh
    yoho access install --network tailscale -d production
    yoho access secrets push -d production
    yoho access add alice --verbs all --tailscale alice@example.com -d production
    yoho access add ci --verbs deploy,releases,rollback --tailscale-tag tag:yoho-ci -d production
    yoho access ls -d production       # MEMBER  VERBS  TAILSCALE  KEYS
    yoho doctor -d production          # tailscaled, Tailscale SSH, the keys command, sshd

    access install --network tailscale needs OpenSSH 8.2 or newer, with Include /etc/ssh/sshd_config.d/*.conf at the top of /etc/ssh/sshd_config (the default on current Debian and Ubuntu), and sshd listening on port 22 on all addresses or the tailnet address. It does four things:

    • installs the keys command and checks it and every directory above it are root-owned and not group or other writable (sshd ignores it otherwise);
    • writes the drop-in and checks it with sshd -t and sshd -T for a tailnet peer, a public peer, a non-tailnet local address and another user;
    • reloads sshd (on every run); if the reload fails it restores the previous drop-in and stops;
    • writes "network": "tailscale" to /etc/yoho/gate.json, only after all of the above succeeded.

    If the effective configuration is not exactly right, the install stops and restores the previous drop-in. For example, a global DenyUsers yoho-gate, or an AcceptEnv that lets clients set SSH_CONNECTION.

    Defaults. On a first install (no /etc/yoho/gate.json) on a Server without systemd, tailscale is the default when the Server is logged in to a tailnet and Tailscale SSH is off; with systemd the default is tsnet, so pass --network tailscale. After that, access install keeps the recorded network until you pass --network or set gate_network on the Destination; a Gate installed before gate.json existed counts as public. Switching warns about Members left without a credential: Members without a Tailscale selector when you switch to tailscale, Members without a key when you switch back to public. --network public removes the drop-in (only if sshd -t and the reload succeed), and restricted keys work again.

Login names are what Tailscale shows in the admin console or tailscale whois (alice@example.com, octocat@github, or a bare headscale user name). Rerunning access add for an existing Member to add a selector keeps its verbs unless you also pass --verbs; a selector is kept when you run it without one; pass --tailscale '' to clear it.

Member: connect over the tailnet ​

The shared Yoho file marks the Destination scoped and tailnet:

yaml
destinations:
  production:
    servers: [main]
    access: scoped
    gate_network: tailscale
    gate_address: web-1.tail1234.ts.net   # the Server's tailnet name (default: servers.main.ssh)

Be on the tailnet (tailscale status) and use the usual commands. The CLI runs ssh yoho-gate@web-1.tail1234.ts.net. Any SSH key works, and no one has to add it. The CLI always offers only its own passphrase-less key, ~/.config/yoho/tailnet-gate_ed25519 (on macOS, ~/Library/Application Support/yoho/), made on first use and passed with -i and -o IdentitiesOnly=yes, so a default key with a passphrase or an agent with many keys never gets in the way:

sh
yoho deploy -d production
yoho app logs web -f -d production

From outside the tailnet, or to the Server's public address, sshd refuses yoho-gate. Removing you from the grant, or your device from the tailnet, revokes access on the next connection.

Deploy from GitHub Actions ​

CI joins the tailnet as an ephemeral node tagged tag:yoho-ci and deploys through the Gate. No SSH key or Access Token is stored, only a Tailscale OAuth client. The runner's throwaway SSH key is made on the fly.

  1. In the Tailscale admin console, create an OAuth client with the auth_keys write scope limited to tag:yoho-ci. Store its ID and secret as TS_OAUTH_CLIENT_ID and TS_OAUTH_SECRET in the repository's secrets.
  2. Add the Member: yoho access add ci --verbs deploy,releases,rollback --tailscale-tag tag:yoho-ci -d production.
  3. Store the Server's verified host key line for the Gate host as the repository variable YOHO_GATE_KNOWN_HOSTS (Yoho's ssh runs in batch mode, so an unknown host key fails the connection). Get it with ssh-keyscan -t ed25519 web-1.tail1234.ts.net from a tailnet device and compare its fingerprint with ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub on the Server.
  4. Use a workflow like this one:
yaml
# .github/workflows/deploy.yml
name: deploy
on:
  push:
    tags: ["v*"]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: tailscale/github-action@v3
        with:
          oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }}
          oauth-secret: ${{ secrets.TS_OAUTH_SECRET }}
          tags: tag:yoho-ci
      - name: Trust the Server's SSH host key
        # The line from `ssh-keyscan -t ed25519 web-1.tail1234.ts.net`, checked
        # once against `ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub` on
        # the Server, stored as a repository variable.
        run: |
          install -d -m 0700 ~/.ssh
          printf '%s\n' "${{ vars.YOHO_GATE_KNOWN_HOSTS }}" >> ~/.ssh/known_hosts
      - name: Install yoho
        run: curl -fsSL https://yohobuild.com/install.sh | sh
      - name: Deploy through the Gate
        env:
          YOHO_ACCESS: scoped
        run: |
          yoho releases -d production
          yoho deploy -d production

The runner's node is ephemeral and disappears when the job ends. The audit log shows the tag and the runner's node name for every request.

What to know ​

  • tailscaled down. The Gate refuses everyone while it cannot ask tailscaled. Operator SSH is unaffected. yoho doctor reports it.
  • Tailscale SSH. Keep it off (tailscale set --ssh=false). While it is on, or its state cannot be read, the Gate refuses every Member and yoho doctor reports an error.
  • sshd settings. Install fails, with a hint, unless sshd listens on port 22 on one of the Server's own tailnet addresses (from tailscale status) or the wildcard of that address's family (0.0.0.0 covers IPv4 only, :: IPv6 only), and unless AllowUsers/AllowGroups admit yoho-gate (by name or one of its groups) and DenyUsers/DenyGroups do not deny it, as sshd -T evaluates them for a tailnet peer. An entry scoped to an address (AllowUsers yoho-gate@100.64.0.0/10) is reported as unverified, a warning: Yoho cannot check it against every Member's address. yoho doctor reports the same.
  • Interrupted switch. If yoho access install --network public stops after removing the drop-in but before sshd reloaded, the next run finishes the reload (or puts the drop-in back if the reload fails again). A network switch always reloads sshd, and gate.json is written only after the reload succeeded.
  • A public Gate on a Server with Tailscale SSH. You may keep Tailscale SSH on a Server whose Gate is public, but then your Tailscale SSH policy must not allow the user yoho-gate: autogroup:nonroot includes it, and a Tailscale SSH session as yoho-gate is a shell, not the Gate. yoho access install and yoho doctor warn while Tailscale SSH is on or unknown. The Gate (on Linux) also refuses a request whose process ancestry includes tailscaled, but that check is best-effort and can be bypassed (a process reparented to init hides its ancestry; unreadable /proc allows the request). The only fix is a Tailscale SSH policy that excludes yoho-gate, or Tailscale SSH off.
  • headscale. Works the same way: it uses the same tailscale CLI and LocalAPI on the Server.
  • WireGuard mesh. The mesh connects Servers for Roles. It carries no Member traffic and is unrelated to a tailnet Gate.