# Remote hosts over SSH and Tailscale

> Run a group's panes on another machine over ssh, from an ssh config alias, user@host or a Tailscale name, with persistence that survives drops.

A group can live on another machine: its panes run there over `ssh`, and its git, pull-request and Files views read from there. The other machine doesn't need Flow; it needs an `ssh` server, and ideally `flow-session` or `tmux` so a session survives a dropped connection.

This is not the same as [Puddles](https://flow.worldbreakstudios.com/docs/sync/flow-remote.md), which links devices that run Flow. A remote host is a server Flow reaches with your own `ssh`.

## What counts as a host

A host is anything `ssh` accepts as a destination:

- an alias from `~/.ssh/config`;
- `user@host`;
- a Tailscale MagicDNS name. Tailscale is not a separate transport: a tailnet machine is an `ssh` destination that Flow finds for you, and Tailscale SSH works through the same plain `ssh` client.

A destination may not be empty, start with `-`, or contain whitespace or control characters.

## Open a session on a remote host

From the command palette (`⇧⌘P`), run **New remote session…** (no default shortcut; bind one in [Keybindings](https://flow.worldbreakstudios.com/docs/configuration/keybindings.md)). It walks four steps:

1. **Host.** Pick a known host or type a destination. Known hosts are listed in this order: recently used, online tailnet machines (with their OS), `~/.ssh/config` aliases, offline tailnet machines, then hosts you only have a profile for.
2. **Directory.** The folders under the host's default directory (`~` unless its profile says otherwise), or type a path. Paths are on the host: `~/src/app` means the remote home. A directory that doesn't exist there starts the pane in `~` with a one-line notice.
3. **Persistence.** How the session survives a dropped connection ([persistence tiers](#persistence-tiers)). The host's profile is preselected, and your pick is written back to it.
4. **Label.** As for a local session.

From the command line:

```sh
flow-cli new-session --host devbox ~/src/app
flow-cli new-session devbox:~/src/app
flow-cli new-session ssh://me@devbox/~/src/app
```

With `--host` and no path, the session starts in `~`. In the one-argument forms, an existing local directory wins over a `name:path` reading.

### How hosts are found

- `~/.ssh/config`: every concrete name on a `Host` line. Wildcard and negated patterns (`*`, `?`, `!`) are skipped, and `Include` files are not followed.
- Tailscale: `tailscale status --json`, from the `tailscale` CLI on your `PATH` or the Mac app's bundled one at `/Applications/Tailscale.app/Contents/MacOS/Tailscale`. A missing, failing or slow (over 3 s) Tailscale just adds nothing.
- Recent hosts: `remote.recent`, the last 20 destinations you used.
- Profiles: any host with `remote.host.<dest>.*` settings.

## Persistence tiers

A remote pane is a local terminal running `ssh` in a reconnect loop. What you reconnect *to* is the tier:

| Tier | Label | Survives a dropped connection | Needs on the host |
|---|---|---|---|
| `auto` (default) | Auto | as the first available of the three below | nothing |
| `flow-session` | flow-session | yes, with Flow's own replay | `flow-session` on the remote `PATH` |
| `tmux` | tmux | yes | `tmux`; Flow runs a dedicated server (`tmux -L flow`) with the status bar and prefix key off, so it behaves like a bare terminal |
| `shell` | Plain shell | no | nothing |

If you force a tier the host doesn't have, the pane falls back to a plain shell and prints "flow: `<tier>` is not installed on this host — this shell will not survive a dropped connection". With **Persist sessions** off, the tier is always a plain shell.

On your Mac, with Persist sessions on, the `ssh` loop itself runs inside a local `flow-session` holder, so quitting and relaunching Flow reattaches to the live connection. The remote tier is what survives your Mac rebooting or the network dropping. See [Persistent sessions](https://flow.worldbreakstudios.com/docs/workspace/persistent-sessions.md).

### Reconnecting

When `ssh` loses the connection (it exits with status 255, for example after sleep or a network change), the pane prints "flow: lost the connection to `<host>` — press Enter to reconnect" and waits. Any other exit ends the loop, so `exit` in the remote shell closes the pane like a local one. Closing a pane or group yourself also ends its remote tier session.

The first pane to a host is interactive: that is where a password prompt, a new host key or a Tailscale check-mode URL appears. Every other `ssh` run (git refreshes, file listings, previews) is non-interactive and fails fast instead of waiting for a prompt.

## Per-host profiles

Each host can carry its own settings. Edit them in **Settings › Advanced › Remote hosts**: each known host has a persistence menu and an **Edit** link that fills a form (default directory, remote shell, extra ssh args). Enter in a field saves it.

| Key | Type | Default | Meaning |
|---|---|---|---|
| `remote.ssh` | string | `ssh` | the ssh program every remote pane and lookup runs ("ssh program") |
| `remote.host.<dest>.persist` | `auto` \| `flow-session` \| `tmux` \| `shell` | `auto` | the host's persistence tier |
| `remote.host.<dest>.root` | string | `~` | the default directory the palette offers first |
| `remote.host.<dest>.shell` | string | the host's `$SHELL`, else `/bin/sh` | the shell the plain-shell tier starts, as a login shell |
| `remote.host.<dest>.ssh_args` | string | (none) | extra ssh options, split like shell words, e.g. `-J bastion` or `-F ~/work/ssh_config` |
| `remote.recent` | JSON array | `[]` | recently used destinations, newest first, at most 20 |

For example, to jump through a bastion for one host:

```sh
flow-cli settings set remote.host.devbox.ssh_args "-J bastion"
```

## Connections

Every `ssh` run to a host shares one multiplexed connection (`ControlMaster=auto`, kept for 10 minutes after the last use, with keepalives every 15 seconds). The first pane pays the handshake; later git refreshes and listings are a channel on the same connection. The control sockets live in a `0700` folder beside your settings file. Your profile's `ssh_args` come after Flow's options, and the destination always comes last.

## Git, pull requests and Files

- **Git** is read on the host: one round trip per refresh reports the repo, branch, head, default branch, origin and change counts. A remote group refreshes at most every 15 seconds.
- **Pull requests** stay local: `gh` runs on your Mac against the repository named by the host's `origin` and the branch, so your GitHub login and Flow's PR cache stay on the Mac. A branch pushed from the host shows up at the next refresh.
- **Files**: a Files tab on a remote group is rooted at the remote path and browses it over the shared connection. Text previews work; images, video and PDFs aren't fetched ("No preview of this kind of file on a remote host"), and listings show no file sizes. **Open** becomes **Copy path**, which copies `host:path`; there is no local app to hand a remote file to. See [Files](https://flow.worldbreakstudios.com/docs/features/files.md).

## Limits

- Remote groups keep the directory they were created in; a `cd` in a pane doesn't move the group.
- Per-pane history, `.flowspace.json` layouts and the group's primary command (`claude` by default) are skipped for remote groups.
- New session's Base step and `drop` worktrees run locally only; there are no remote worktrees yet.
- The Task Manager and tab titles see only the local `ssh` process.
- Port forwarding for web tabs is not available: a dev server on the host's `localhost` doesn't open in a web tab.
- Remote files can't be opened in an editor, only copied as a path.
