Reference
ops-gate has no settings outside this page and no defaults: the server's settings are files in fixed places, and everything else is in the verb table. A missing file or key stops the gate with an error instead of being guessed at.
Commands
| Command |
Runs as |
Does |
ops-gate serve |
The agent's user, as the SSH forced command |
Runs SSH_ORIGINAL_COMMAND through the gate |
ops-gate sudoers TABLE |
Anyone |
Prints the sudoers drop-in the table allows |
ops-gate keygen KEY |
The approver |
Writes a new Ed25519 private key as hex to KEY (mode 0600, never over an existing file) and prints the public key as hex |
ops-gate approve --key KEY --table TABLE --host HOST WORDS… |
The approver |
Prints WORDS… approval=…, signed for HOST with the table's purpose, expiring after its approval_seconds |
ops-gate update |
root, from a timer |
Installs the approver-signed tables waiting for this host |
serve exits with the highest exit status of the verb's steps, or 2 when it refuses the call.
Environment
| Variable |
Read by |
Meaning |
SSH_ORIGINAL_COMMAND |
serve |
The command the agent sent, set by sshd for a forced command. Without it the call is refused with "no command given". |
No other environment variable is read.
Files on the server
| Path |
Read by |
Content |
/etc/ops-gate/verbs.toml |
serve, update |
The verb table; readable by the agent's user, writable only by root |
/etc/ops-gate/host |
serve, update |
This server's name, as approvals name it, e.g. main |
/etc/ops-gate/approver.pub |
serve, update |
The approver's Ed25519 public key as 64 hex characters |
/etc/ops-gate/approvals-url |
update |
The https:// URL of the waiting table approvals, with {host} where the host name goes |
/var/lib/ops-gate/state.json |
serve |
Rate limit counters and spent run approvals; starts as {"calls": {}, "used": {}} and belongs to the agent's user, as does its directory, where the gate keeps state.lock |
/var/lib/ops-updater/used.json |
update |
Spent table approvals; starts as {}, root only |
/etc/sudoers.d/<user> |
sudo |
The rules ops-gate sudoers generates; update replaces it |
Surrounding whitespace in the three one-line files is ignored. Both state files must exist before the first run.
The verb table
Every top-level key and every apps key is required.
Top-level keys
| Key |
Type |
Meaning |
RetroSpeedLab |
user |
string |
The agent's Unix user; the sudoers rules are for it and their drop-in is named after it |
"maintainer-ops" |
purpose |
string |
Signed into every approval, so signatures for one deployment never count for another |
"retro-speedlab-ops" |
programs |
list of absolute paths |
The only programs a step, or apps.list, may run |
/usr/bin/df, docker, dokku, du, journalctl, sha256sum |
hosts |
list of strings |
The servers this table is for. The gate only requires the key; a signer uses it to sign a table approval per host, as RetroSpeedLab's backend does |
["main", "home-lab"] |
approval_seconds |
integer |
The longest an approval may stay valid, counted from when the gate checks it; ops-gate approve signs for exactly this long |
900 |
output_characters |
integer |
How much of each step's output the agent gets back, from the end |
12000 |
step_seconds |
integer |
The timeout of each step, and of the app listing |
600 |
apps |
table |
How to list the platform's apps, below |
|
limits |
table of tables |
The rate limits verbs refer to, below |
|
arguments |
table of tables |
The typed arguments verbs take, below |
|
verbs |
table of tables |
The verbs, below |
|
[apps]
| Key |
Type |
Meaning |
RetroSpeedLab |
list |
argv |
Lists the apps on this server, one per line; run through sudo, so its program must be in programs |
["/usr/bin/dokku", "apps:list"] |
header |
string |
Lines of the listing that start with it are not apps |
"=====>" |
pattern |
regular expression |
What an app name looks like in the sudoers rules |
"[a-z0-9-]+" |
never |
list of apps |
Never a restartable-app |
["retro-speedlab-maintainer"] |
guarded |
list of apps |
Only a guarded-app, never a restartable-app |
["bugs", "retro-speedlab-experiments-postgres"] |
[limits.<name>]
| Key |
Type |
Meaning |
calls |
integer |
How many calls of the verbs with this limit may run |
seconds |
integer |
Within this sliding window, on this host |
RetroSpeedLab has reads (60 an hour), repairs (3 an hour) and approvals (6 an hour).
[arguments.<name>]
| Key |
Type |
Meaning |
kind |
string |
integer, choice, app, restartable-app or guarded-app (see argument kinds) |
minimum, maximum |
integer |
For integer: the inclusive bounds |
values |
list of strings |
For choice: the accepted values |
[verbs.<name>]
| Key |
Type |
Meaning |
class |
string |
read, repair or approval (see classes) |
limit |
string |
The name of a [limits.<name>] table |
arguments |
list of strings |
Names of [arguments.<name>] tables, in the order the agent passes them |
steps |
list of argv |
The commands to run, in order; {argument} is replaced by its value, and a step may only use arguments the verb takes |
about |
string |
What the verb does, for the agent and the reviewer; the gate does not read it |
A verb name is a single plain word, since the agent sends it as the first word of the command.
Python API
A backend that signs approvals uses ops_gate.approval:
| Function |
Returns |
sign_run(key, purpose, host, words, expiry) |
The run approval token approval=<expiry>.<nonce>.<signature> for the command words (a tuple) on host |
sign_table(key, purpose, host, commit, table, expiry) |
The table approval as a dict with host, commit, digest, expiry, nonce, signature and table, ready to serve as JSON from the approvals URL |
TOKEN |
The regular expression a run approval matches; its groups are the expiry, the nonce and the signature |
key is a cryptography Ed25519PrivateKey, expiry a Unix time in seconds no further ahead than the table's approval_seconds. The approvals URL serves a JSON list of table approvals; an empty list means nothing is waiting.
Logs
| Identifier |
Facility |
Lines |
ops-gate |
auth |
ran '<words>': exit <status>, or refused '<command>': <reason> |
ops-updater |
auth |
installed the table of <commit> (<digest>), or refused an approval: <reason> |