Skip to content
Releases

Sync a vault across machines

A vault on one machine stays a local file. Connect it to a flint-vault-server you run, and every machine you connect keeps its own full copy of that vault in step with the others. It is local-first: each machine works on its own copy, offline too, and the server only passes the encrypted file between them. Vaults you do not connect stay on their own machine; the ones you do can all share one server, each kept apart under its own id.

Everything here works from the desktop app and from the CLI; each section shows both.

On the machine that has the vault, with the server’s URL and token at hand.

In the app: open the vault, then Settings → Vault → Server → Connect to a server…. Type the server’s address, paste the token, give it a label if you like, and type the vault’s master password again. The strength meter shows whether it is strong enough; Connect stays off until it is. The dialog ends with what happened: Uploaded (the server did not keep this vault yet) or Merged with the server’s copy (it already did).

From the CLI:

Terminal window
flint vault connect https://vault.example.com --label Home
Server token: ••••••••
Master password for 'home': ••••••••
Connected vault 'home' to https://vault.example.com and uploaded it (version 1).
The server lists it as 'Home'.
On another machine: `flint vault connect https://vault.example.com --to <path>` (with `--id 0a1b2c3d` when the server keeps several vaults).

One server keeps as many vaults as you connect to it, with the same token: connect Work the same way and it goes beside Home, with its own versions.

The label tells your vaults apart on another machine, since the server cannot read a vault’s name. It is optional, at most 64 characters, and the server keeps it in clear: leave it out when the name itself is private, and the vault shows by its id alone.

Flint checks three things before the vault leaves the machine:

  • https://. Plain http:// is refused for anything but this machine (localhost, 127.0.0.1): your reverse proxy does TLS (Self-host a remote vault).
  • A strong master password, Strong (3 of 4) or better. The file will sit on a disk where it can be attacked offline; change a weaker one first with flint vault passwd.
  • The vault’s own master password, typed for this command.

The token goes to the OS keychain (macOS Keychain, the Secret Service on Linux), never to a file. While the desktop app holds the vault unlocked, flint vault connect is refused: connect it from the app, or lock it there first.

In the app: on the Welcome screen (or from the vault switcher, ⇧⌘O, or Remote vault… at the foot of the unlock screen), choose Connect to a remote vault (⌥⌘O). Type the server’s address and paste the token; Continue checks them with the server. The server cannot read a vault, so all it shows is its label (if it was given one), its size, its version and when it last changed; a server that keeps several lists them, and you pick one. Type that vault’s master password, choose where to keep the local copy, and Download and open. The vault opens in the window, already connected. The other vaults on the server stay there: a machine downloads only the ones you choose.

From the CLI, list what the server keeps, then download one to a new file:

Terminal window
flint vault connect https://vault.example.com --list
ID LABEL VERSION SIZE UPDATED
0a1b2c3d4e5f60718293a4b5c6d7e8f9 Home 14 1.2 MB 2 h ago
7be04f1a22c3d4e5f60718293a4b5c6d Work 3 340 KB 9 days ago
Terminal window
flint vault connect https://vault.example.com --to ~/Vaults/work.flint --id 7be0

--id takes the vault’s id or its first characters (4 or more, as long as only one vault starts with them); with a single vault on the server it is not needed. Flint opens the server’s copy with the master password you type before it writes anything; a path that already holds a file is refused. The new file is an ordinary vault, already connected.

A machine that already has a copy of the same vault (from a cloud folder, say) connects it with plain flint vault connect <url>: the two copies are merged.

You do not run anything after connecting. Changes travel both ways:

  • In the desktop app, while the vault is unlocked: at unlock, a few seconds after a change (a burst of changes makes one upload), when the window comes back to the front, and about every 60 seconds to pick up other machines’ changes. Each check asks the server whether its copy changed, and downloads it only if it did.
  • From the CLI on its own, without the app: right after a command that changed the vault. If the server cannot be reached, the command still succeeds, says so, and the change waits.
  • On demand: flint vault sync.

The 60 seconds is Settings → Vault → Server → Check every: 1 min, 5 min, 15 min, or Only on changes and at unlock (it is sync_interval in your config folder’s settings.json, in seconds: 60, 300, 900 or 0). Sync now is beside it, in the status bar’s sync menu and in the command palette (Sync vault now).

When a sync brings other machines’ changes, the app says so in a toast (Changes from another machine: 2 hosts added, 1 updated). Details lists what changed, by kind and by name (labels only, never a secret), and what the merge did, such as a renamed alias. Show last merge in the command palette opens it again.

Terminal window
flint vault sync
Synced vault 'home' with https://vault.example.com: 1 added, 0 updated, 0 removed here, and this machine's changes uploaded (version 7).
CHANGE KIND NAME
added host db

Every machine keeps working without the server: hosts on your network still connect, and edits are kept. When the server is back, each machine’s next sync takes the others’ changes and sends its own.

When two machines changed the vault apart, the second to upload is told another machine went first (409). It downloads that copy, opens it with the key it already holds, merges it with its own record by record, and uploads the result. The merge is the one flint vault merge uses: a record changed on both keeps the later change, a record removed on one stays removed unless the other changed it afterwards, and everything else from both is kept. When both added a host with the same alias, the one added first keeps it and the other becomes web-2, and the report says so.

A machine never replaces its own copy with a download: the download is merged into it, in one transaction, so nothing typed on this machine is lost. And it never uploads over a version it has not merged.

A master password changed on another machine

Section titled “A master password changed on another machine”

flint vault passwd on a connected vault syncs first, then changes the password, then uploads the re-keyed vault; it is refused while the server cannot be reached, so no other machine’s change made under the old password is left behind.

The other machines’ next sync cannot open the new copy with the old key:

flint: the vault's master password was changed on another machine: sync again with the new one (`flint vault sync` asks for it)

flint vault sync asks for the new master password (or reads it with --new-master-stdin), re-keys this machine’s copy to it, merges and uploads. The app asks for it in its window: The master password of home was changed on another machine. Type the new one and Sync; from then on this machine’s vault opens with it too. Later leaves the status bar saying Needs the new password until you click it.

In the app, the status bar shows the sync’s state beside the lock state, with a cloud:

State What it means
In step This machine and the server hold the same version; hover for when it last synced
Syncing… A sync is under way
Waiting Changes made here wait to be uploaded
Offline The server cannot be reached; changes wait here and go up when it is back
Merged Another machine’s changes just came in; click for the details
Needs the new password The master password was changed on another machine; click to type it
Token refused The server refused this machine’s token; the app stops syncing this vault on its own (below); click for Sync now and Replace token…
Needs attention The server answered without syncing (it asks this address to wait, or refused the request); click for Settings, where its message is shown

Clicking it shows the last sync, the server, the version, Sync now and Server settings…. A vault that is not connected shows nothing there. The vault switcher marks connected vaults with a cloud, and the unlock screen says when changes from this machine wait for the unlock.

From the CLI, flint vault status shows the server, the version last merged, when the last sync was, and whether this machine holds changes the server does not have yet:

vault home
path /Users/me/Vaults/home.flint
state unlocked in Flint
...
remote https://vault.example.com
version 7
last sync 2 min ago
waiting nothing

A failed attempt shows as last attempt, with its error. With --json it is the remote object: connected, url, version, last_sync and last_attempt (Unix milliseconds), last_error, pending.

When the server answers that the token is wrong (HTTP 401), the app stops syncing that vault on its own: no retry on a timer, at unlock, when the window comes back or after a change. Every wrong token counts against the server’s lockout, and behind a home or office router every machine reaches the server as one address, so a few machines still holding an old token would lock all of them out (see how the server counts clients).

It syncs again when you act:

  • Sync now (status bar, Settings, or the palette) tries once more; refused again, it stays paused.
  • Replace token… with the right one: the app checks it with the server, keeps it and syncs at once.
  • A restart of the app tries once. Nothing about the pause is kept on disk.

Changes made meanwhile stay on this machine and go up with the next sync that works. The CLI keeps no state between commands: a command that changes the vault still tries once after it, and flint vault sync says the token was refused.

When the server asks this address to wait (HTTP 429: too many requests, or too many wrong tokens in a short time), the message says for how long (asks this address to wait 14 min), and the app tries again after a pause that doubles up to 15 minutes.

When the server’s token was rotated, give each machine the new one:

Terminal window
flint vault token

It asks for the new token (or reads it with --token-stdin), tries it against the server, and only then replaces the old one in the keychain. A token the server refuses changes nothing. In the app: Settings → Vault → Server → Replace token…, which checks it the same way.

In the app: Settings → Vault → Server → Disconnect…, or Disconnect vault from server… in the command palette. From the CLI:

Terminal window
flint vault disconnect

This machine stops syncing the vault and forgets the token. The vault file stays as it is, and so does the server’s copy and every other machine’s.

What Where
The vault Its .flint file, wherever you keep it
The server’s URL, the version last merged, a hash of the file at the last sync remotes.json in the config folder: no host, user or label
The server’s token The OS keychain, account remote-token:<vault id>

Without an OS keychain (FLINT_KEYCHAIN=off, or a Linux machine with no Secret Service), vault connect is refused: the token is never kept in a file.

On macOS, from 0.40.0, a token is kept with an access list naming the desktop app and the flint CLI inside it, each by its Developer ID signature: either reads a token the other saved with no question, and so does every later version signed by the same developer. Any other program that asks for it gets the Keychain’s question. A token saved by an earlier version gains that list the first time the program that saved it reads it; until then, the other one may ask once (choose Always Allow), and the app’s sync waits for the answer. A Flint you build yourself and sign ad hoc gets no such list: each build is a new program to the Keychain, which asks again.