onecli 3.4 or later where you make the token, signed in with onecli login. The place you connect needs only sh and curl. See the Quickstart.
Make a connect token
Find the vault the agent should use:docker or aws-ec2:
--expires-in (1m to 60m). It is a credential: pass it only to the place it is for, and don’t log or save it.
Use install_command where onecli is not installed. Use connect_command where it is. Run either one as the user the agent runs as. It writes agent.env (mode 0600) with the agent’s credential and proxy settings, and a line in the shell profile that reads it.
Docker
Runinstall_command inside the running container:
install_command in place of <install_command>, as it is. The script sees it runs in a container and records the agent’s runtime as docker.
If you self-host OneCLI on the same machine at a localhost address, the container reaches it through host.docker.internal. Start the container with --add-host=host.docker.internal:host-gateway when it cannot resolve that name.
Proxy settings only route tools that respect them. To make the gateway the container’s only way out, see Lock down Docker and Linux agents.
Your own server
Open a shell on the server, as the user the agent runs as, and runinstall_command there. For example over SSH:
agent.env, so start the agent from one, such as a new SSH session. For a systemd service, read agent.env in ExecStart, as in the Linux lock-down recipe.
CI
A CI runner that stays up, such as a self-hosted runner, is a server: connect it once, as above, and its jobs readagent.env.
A job on a fresh runner cannot use a connect token, because a token works once. Give CI its own agent instead. Its credential (oc_agent_...) reaches one vault and can only call APIs through the gateway. Never put your managing key in CI: it manages every vault you can use.
1
Make the CI agent once, on your own machine
Use a vault that holds only the items CI needs. Make the agent with the managing key On Linux, use
onecli login saved, and give it an expiry. We recommend 30 days, so a leaked credential stops on its own. The API takes 5 minutes to 90 days.date -u -d '+30 days' +%Y-%m-%dT%H:%M:%SZ. The key goes to curl as a header file, so it is not in the command line other users on the machine can list. The answer holds the credential once. The pipe stores it straight in a CI secret, so it never shows on screen. The answer also holds the agent’s id, vaultId, expiresAt and gateway.2
Connect in the job
Run the connection script with the credential instead of a token. It writes A login shell reads
agent.env and the gateway certificate:agent.env, so the agent’s calls go through the gateway.3
Replace it before it expires
When the agent reaches its
expiresAt, its calls answer 401. Make a new one as in the first step, and disconnect the old one with onecli agents disconnect <agent-id> --yes.CI set, onecli never asks a question and never updates itself.
Check the agent is connected
401:
200, because the gateway added the Test key. A login shell reads the proxy settings:
docker exec research-container sh -lc '...'.