# Secrets for servers and CI

Run any command with its secrets injected as environment variables, without writing a single file. Authsidian never sees them in the clear.

## Overview

### What authsidian run does

`authsidian run` starts a command and hands it its secrets as environment variables. It reads them from Authsidian at launch, decrypts them in memory on your own machine and never writes them to disk. It replaces `infisical run` or `doppler run`.

```bash
authsidian run -p myapp -e production -- docker compose up -d
```

`-p` is the project and `-e` the environment. Everything after `--` is the command to run. On Linux and macOS the CLI replaces itself with that command, so signals, the terminal and the exit code pass straight through and no extra process is left behind.

> **Where you manage it.** In the Authsidian desktop app (0.1.9 or later), the **Secrets** section creates environments, stores their secrets and manages machines. On iPhone, iPad and Android (2.0.3 or later) you can look them up and revoke a machine if you lose a server.

### When to use it

- A VPS or dedicated server that runs your app with Docker Compose or systemd.
- CI/CD runners that need credentials during a build, a test run or a deploy.
- Any process that today reads a `.env` file you would rather not keep on disk.

People keep using the Authsidian app; servers use the CLI. Server secrets belong to your account (Pro) or to your team, so there is nothing extra to subscribe to.

### How it works

| Concept | What it is |
| --- | --- |
| Project and environment | A pair of names such as `myapp` and `production`. Each pair is one encrypted vault of `NAME=value` secrets. |
| Machine | An identity for a server or a pipeline, not for a person. It signs in with a token, can only read, and only sees the vaults you grant it. It can expire, be limited to IP addresses and be revoked. |
| Token | A long secret string that starts with `asm1.`. It is shown once, when you create the machine. |

Every time you run a command:

1. **The CLI signs in**

   It derives the machine keys from the token and signs in with a derived key, so the token itself is never sent.

2. **Authsidian answers with ciphertext**

   It returns an access token valid for 10 minutes, plus the encrypted vault key and the encrypted secrets the machine was granted.

3. **The CLI decrypts in memory**

   It opens the vault key with the machine private key and decrypts the secrets.

4. **Your command starts**

   It gets those variables and nothing else. The token variables are not passed to it.

### What Authsidian can see

| Item | On Authsidian servers |
| --- | --- |
| Secret names and values | Never in the clear. Values are encrypted and names are stored only as a keyed hash. |
| Project and environment names | Encrypted inside the vault metadata. |
| Machine name, expiry, allowed IPs and last use | Readable. Do not put secrets in a machine name. |
| The machine token | Never stored. Only a verifier (a hash) is kept. |

## Get started

### Requirements

- An Authsidian account with Pro, or a team with an active plan.
- That account on v2 keys: new accounts get them, and existing ones are upgraded when you sign in with the latest app.
- The Authsidian desktop app 0.1.9 or later, to create environments and machines. The admin script below does the same from a terminal.
- On the server: Linux, macOS or Windows, and outbound HTTPS to `api.authsidian.com`.

### Quickstart

1. **Install the CLI on the server**

   ```bash
   curl -fsSL https://authsidian.com/install.sh | sh
   ```

   The script downloads the binary for your system, checks its SHA-256 and installs it in `/usr/local/bin`. On Windows, download [authsidian_windows_amd64.exe](https://downloads.authsidian.com/cli/latest/authsidian_windows_amd64.exe) and check it against [SHA256SUMS](https://downloads.authsidian.com/cli/latest/SHA256SUMS).

2. **Create an environment**

   In the desktop app open **Secrets → New environment** and enter the project and the environment, for example `myapp` and `production`. It can belong to your account or to a team you administer.

3. **Add your secrets**

   Use **Add secret**, or **Import .env** to bring a whole file at once. Values are encrypted on your computer before they leave it.

4. **Create a machine**

   Open **Secrets → Machines → New machine**: give it a name, an expiry, the IP addresses of your server and the environments it can read.

   > **The token is shown once.** Copy it when the app shows it. It cannot be shown again; if you lose it, revoke the machine and create another.

5. **Save the token on the server**

   ```bash
   install -d -m 0700 /etc/authsidian
   install -m 0600 /dev/null /etc/authsidian/token
   read -rsp 'Token: ' T && printf '%s' "$T" > /etc/authsidian/token; unset T
   ```

6. **Run your app with it**

   ```bash
   authsidian run --token-file /etc/authsidian/token -p myapp -e production -- ./start-server
   ```

## Guides

### Run any command

`authsidian run` does not care what you start after `--`. Your app reads the variables the way it always did, for example `process.env.DATABASE_URL` or `os.environ["DATABASE_URL"]`, and never knows Authsidian exists. Docker is only one option.

Node.js:

```
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- node server.js
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- npm start
```

Python:

```
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- python app.py
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- gunicorn app:app
```

Binary or script:

```
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- ./myapp --port 8080
```

Local development:

```
export AUTHSIDIAN_TOKEN=asm1.…
authsidian run -p myapp -e development -- npm run dev
```

On your laptop, use a machine that can only read the development environment, so nobody needs a `.env` file.

```cron
*/10 * * * * /usr/local/bin/authsidian run --token-file /etc/authsidian/token -p myapp -e production -- /opt/myapp/sync.sh
```

cron has a minimal `PATH`, so write the full path to `authsidian` and to your script.

Shell expansion:

```
authsidian run -p myapp -e production -- sh -c 'curl -H "Authorization: Bearer $API_KEY" https://api.example.com/health'
```

If the command itself needs a variable expanded, let the child shell do it: single quotes stop your own shell from expanding it before `authsidian` has set it.

PowerShell:

```
authsidian.exe run --token-file C:\ProgramData\authsidian\token -p myapp -e production -- node server.js
```

On Windows the CLI cannot replace itself with your command, so it runs it as a child process and returns its exit code.

### Docker Compose

Declare the variable names without values, so Compose takes them from the environment that `authsidian run` sets up.

compose.yaml:

```
services:
  app:
    image: myapp:latest
    environment:
      - DATABASE_URL
      - JWT_SECRET
```

```bash
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- docker compose up -d
```

Without Compose, pass the names with `-e` and no value; Docker takes them from the environment.

docker run:

```
authsidian run --token-file /etc/authsidian/token -p myapp -e production -- docker run --rm -e DATABASE_URL -e JWT_SECRET myapp:latest
```

> **Containers can leak them.** Secrets passed to a container are visible with `docker inspect` and to `root` on the host.

### systemd

myapp.service:

```
[Service]
ExecStart=/usr/local/bin/authsidian run --token-file /etc/authsidian/token -p myapp -e production -- /usr/local/bin/myapp
Restart=on-failure
```

Because `run` replaces itself with your app on Linux, systemd tracks the app process directly. Secrets are read on every start, so restart the unit to pick up changes.

### CI pipelines

Create one machine per pipeline and environment, and store its token as a secret of your CI provider named `AUTHSIDIAN_TOKEN`. This example is for GitHub Actions:

.github/workflows/test.yml:

```
- name: Test with secrets
  env:
    AUTHSIDIAN_TOKEN: ${{ secrets.AUTHSIDIAN_TOKEN }}
  run: authsidian run -p myapp -e staging -- npm test
```

Runners change IP address, so skip `--cidr` for them and use a short expiry (`--days`) instead. Signing in without a stored token (OIDC) is not available yet.

## Reference

### CLI reference

| Command | What it does |
| --- | --- |
| `authsidian run -p <project> -e <environment> -- <command> [args]` | Runs the command with the secrets as environment variables. Writes no files and returns the exit code of the command. |
| `authsidian export -p <project> -e <environment> [--format dotenv\|json\|shell] [--output <file>] [--force]` | Prints the secrets to standard output. With `--output` it creates a file with mode 0600 and refuses to overwrite one without `--force`. Use it only when `run` is not possible. |
| `authsidian projects` | Lists the projects and environments the machine can read. |
| `authsidian version` | Prints the version. |

| Variable or option | Meaning |
| --- | --- |
| `AUTHSIDIAN_TOKEN` | The machine token. The alternative is `--token-file`. |
| `--token-file <file>` | Reads the token from a file. The CLI warns if other users can read that file. |
| `AUTHSIDIAN_API_URL` | API address. Defaults to `https://api.authsidian.com`. It must be https; http is accepted only for localhost. |

None of these variables reach your command. If a secret has the same name as an inherited variable, the secret wins.

| Exit code | Meaning |
| --- | --- |
| The command’s own | What `run` returns when the command ran. |
| `1` | Something failed: sign-in, network or access. |
| `2` | Wrong usage. |
| `127` | The command does not exist. |

More examples:

```bash
authsidian projects
authsidian export -p myapp -e production --format dotenv --output .env
authsidian export -p myapp -e production --format json
```

### Admin script reference

For automation or without the desktop app. Run it with `node scripts/secrets-admin/cli.ts <command>` from the Authsidian repository (Node.js 24 or later). Set `AUTHSIDIAN_EMAIL` (and `AUTHSIDIAN_API_URL` if you need another API). The master password is asked without echo.

| Command | What it does |
| --- | --- |
| `account register` | Creates the account with v2 keys. |
| `account migrate` | Moves a v1 account with no items to v2 keys. |
| `vault create -p <project> -e <environment> [--name <text>] [--team <id>]` | Creates the vault for a project and environment. Without `--team` it belongs to your account. |
| `vault list` | Lists your secret vaults. |
| `vault rotate -p <project> -e <environment>` | Re-encrypts the vault with a new key and re-grants every machine that still has access. Do it after revoking a machine. |
| `secret set -p <project> -e <environment> NAME [VALUE \| -]` | Sets a secret. A `-` reads the value from standard input. |
| `secret unset -p <project> -e <environment> NAME` | Deletes a secret. |
| `secret list -p <project> -e <environment> [--reveal]` | Lists the secret names. With `--reveal` it shows the values too. |
| `secret import -p <project> -e <environment> <file.env>` | Imports every `NAME=value` from a dotenv file. |
| `machine create <name> [--days N] [--cidr a,b] [--team <id>]` | Creates a machine and prints its token once. |
| `machine list` | Lists your machines. |
| `machine grant <machine-id> -p <project> -e <environment>` | Lets the machine read that vault. |
| `machine revoke <machine-id>` | Cuts the machine’s access at once. |

### Use with AI assistants

This guide is also available as [Markdown](https://authsidian.com/docs/servers.md), in [llms.txt](https://authsidian.com/llms.txt) and as a read-only MCP server, so an AI assistant can answer with the right commands and limits. The MCP server only serves this public documentation: it cannot see your account, your vaults or your secrets.

```bash
claude mcp add --transport http authsidian-docs https://authsidian.com/mcp
```

```json
{
  "mcpServers": {
    "authsidian-docs": { "type": "http", "url": "https://authsidian.com/mcp" }
  }
}
```

> **Tokens.** Never paste a machine token or a secret into an assistant.

### Limits and plans

| Limit | Value |
| --- | --- |
| Machines per account or team | 20 |
| Secret vaults per account | 50 |
| Secrets per vault | 5,000 |
| Machine sign-ins | 10 per minute per IP address |
| Machine reads | 30 per minute per machine |

These are starting values and may change. When a rate is exceeded the API answers `429` with a `Retry-After` header; when a count is exceeded it answers `409 limit_reached`.

If your plan expires, machines keep reading their secrets, so a failed payment does not take your servers down. Creating or editing secrets, vaults and machines stops until the plan is active again.

## Security

### Security model

- **The token is a secret.** Anyone who has it can read what the machine was granted. Keep it in a file with mode 0600 or in your CI secret store, and use one machine per server and environment.
- **Machines only read.** They cannot create, edit or delete secrets.
- **Limit the damage.** Set an expiry (`--days`) and, for servers with a fixed address, the allowed IPs (`--cidr`). Every request is checked against both.
- **Revoking is immediate,** but it cannot undo what the machine already read. After revoking, rotate the vault and change the secret at its source.
- **It fails closed.** If the API cannot be reached at launch, the command does not run (3 attempts with short waits). Processes that are already running are not affected.
- **Root can read it.** Anyone with root on the server can read the token and the secrets in memory, as with any secrets manager. Memory is cleared on a best-effort basis; the language does not guarantee it.

### Troubleshooting

| Symptom | Cause and fix |
| --- | --- |
| `invalid_credentials` (401) | The token is wrong or revoked, the machine expired, or the request comes from an IP that is not allowed. The API gives the same answer for all of them, but the desktop app (**Secrets → Machines**) and `machine list` show the last rejection with its reason and the IP it came from. |
| `429` | Too many requests. Wait the seconds given in `Retry-After`. |
| The command does not start and the API is down | By design: nothing runs without its secrets. Try again when the API is back. |
| You changed a secret but the app has the old one | `run` reads the secrets once, at launch. Restart the service. |
| A Docker Compose variable is empty | Declare its name without a value under `environment` in `compose.yaml`. |
| `403 plan_inactive` while creating something | The plan is not active. Reads keep working; renew the plan to write again. |
| `409 limit_reached` | You reached the limit of machines or vaults. |
| `409 name_taken` | A secret with that name already exists in the vault. |
