Forwarding over SSH
fnox forward serve lets a host you SSH into read secrets that are resolved on your own machine, much as ssh -A lets it use your SSH keys. Your password manager, keys, and approval prompts stay local. The remote needs no provider CLI, token, or synced copy. Linux, macOS, FreeBSD, and OpenBSD only.
List what may be forwarded
Use the same config on both hosts, usually the project's fnox.toml:
[forward]
secrets = ["GITHUB_TOKEN"]
[providers.op]
type = "1password"
vault = "Engineering"
[secrets]
GITHUB_TOKEN = { provider = "op", value = "GitHub/token" }Nothing is forwarded unless it is listed. Each side reads the list for itself:
- the serving host answers only for the names in its list;
- the remote asks the serving host for the names in its list, and resolves every other secret itself.
The remote doesn't have to define a listed secret. When it doesn't, the name in its list is enough, so a secret that only one machine defines, such as one in an untracked fnox.local.toml, needs no copy of its definition on each host. This is a whole remote config:
# ~/.config/fnox/config.toml on devbox
[forward]
secrets = ["GITHUB_TOKEN"]When the remote does define a listed secret, it is forwarded only if it has a value (or a synced copy). Secrets that only have a default or come from the environment stay local, and lease credentials are not forwarded.
While FNOX_FORWARD_SOCK is set, a secret that fails on the remote because it isn't in the remote's list comes with a warning that says so, since the error itself is usually about a provider CLI the remote doesn't have.
Connect
On your machine, in the project directory:
fnox forward serveIt prints the socket it listens on and keeps running until you stop it. In another terminal, forward that socket to a path on the remote, then point fnox at it there:
ssh -R /home/me/.fnox-forward.sock:/path/printed/by/serve devbox# on devbox
export FNOX_FORWARD_SOCK=/home/me/.fnox-forward.sock
fnox exec -- ./deployBoth paths in -R must be absolute. sshd leaves the remote socket file behind when the connection ends, and refuses to replace it on the next one unless its config has:
# /etc/ssh/sshd_config on the remote
StreamLocalBindUnlink yesWithout that setting, delete the file on the remote before reconnecting.
To make it the default for one host, in ~/.ssh/config on your machine:
Host devbox
RemoteForward /home/me/.fnox-forward.sock /path/printed/by/serveUse fnox forward serve --socket PATH to choose the local path yourself. Put it in a directory only you can write to.
What happens on each read
The remote sends the secret names. The serving host resolves them with the config and profile forward serve started with (with use_daemon, the current config), prints the names in its terminal, and returns the values. Provider prompts, such as 1Password approval or a YubiKey PIN, appear on your machine.
The serving host's definition of a name wins: the remote's provider, value, and json_path for a forwarded secret are not used. Run forward serve from the project, and with the profile, whose values you mean to share. Restart it after changing [forward].
When the serving host can't be reached or refuses a name, the secret fails like any provider error from its own provider would, and a default is used if it has one. A provider setting that names a forwarded secret, such as token = { secret = "VAULT_TOKEN" }, reads it from the serving host too.
fnox sync and fnox reencrypt never use forwarding. They read from the secret's own provider, so run them on a host that has it.
Repeated reads
By default forward serve does not use the daemon: each request is read from the provider. Whether that prompts each time is up to the provider. The 1Password CLI, for example, asks once and then reuses its own session until it has been idle for a while, and forward serve keeps that session because it runs as one long process.
A remote that reads the same secret often, such as a Docker credential helper on every pull, can be served from the daemon's cache instead:
# on your machine
[forward]
secrets = ["GITHUB_TOKEN"]
use_daemon = true
[daemon]
enabled = true
cache_ttl = "15m"Forwarded reads then follow the daemon's rules: cache_ttl and max_cache_ttl, daemon_cache = false on a secret or provider, and fnox daemon clear or --refresh after rotating a value. Values stay in memory on your machine. While a value is cached, the remote reads it without a prompt, so keep the TTLs short for secrets behind an approval. Entries are kept apart from your own commands' unless share_across_commands is set, and fnox daemon status lists them with the purpose forward.
The daemon reloads changed config files for each read, so with use_daemon a secret's definition follows your edits. The [forward] list still stays as forward serve started; restart it to change the list.
A synced copy on your machine is another way to avoid repeat vault calls.
The remote never puts forwarded values in a daemon, and holds them only as any read does, so as_file secrets become temporary files.
Security
While the socket is forwarded, any process on the remote running as you (and root there) can read every listed secret, as with ssh -A. So:
- list only what the remote needs, and forward only to hosts you trust;
- stop
forward servewhen you are done.
The remote can send names and nothing else. It cannot choose a directory, config, profile, or environment on your machine, store anything, or read a name that is not listed.
With auditing on, your machine records these reads with the command forward.
Don't forward the daemon socket
The daemon socket is only for your own machine. Its clients choose the working directory, config, and environment the daemon resolves with, and can write to its cache. Forward only the forward serve socket.