> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# bach key: make access keys

> bach key: prints random access keys for an app with [access], one per line, ready to use as BACH_ACCESS_KEY or to hand to customers.

`bach key` prints random access keys for an app with [`[access]`](/docs/reference/config/access). It needs no config and changes nothing.

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach key
bach key --count 50 --out keys.txt
```

```console theme={"theme":{"light":"github-light","dark":"github-dark"}}
$ bach key
TH6C-PLW3-M6SM-KYYW-K86H
```

| Flag | Default | Meaning |
| - | - | - |
| `--count N`, `-c N` | `1` | How many keys to make, from 1 to 10000 |
| `--out FILE`, `-o FILE` | none | Write the keys to this new file, as UTF-8 text, one per line, instead of printing them. An existing file is never overwritten. |

A key has 100 bits of randomness from the system's random generator, in groups of four with no characters that look alike (no `0`, `O`, `1` or `I`). Keys are case sensitive and exact.

Use one with a build. The simplest way works in every shell: put the key in a file and pass the file.

```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
bach key --out key.txt
bach build --key-file key.txt
```

`--key-file` uses the first line of the file, so a file made with `--count 50` works too, with its first key. The build can also read the key from an environment variable, which each shell sets in its own way:

```powershell PowerShell theme={"theme":{"light":"github-light","dark":"github-dark"}}
$env:BACH_ACCESS_KEY = "TH6C-PLW3-M6SM-KYYW-K86H"; bach build
```

```bat cmd theme={"theme":{"light":"github-light","dark":"github-dark"}}
set BACH_ACCESS_KEY=TH6C-PLW3-M6SM-KYYW-K86H && bach build
```

```bash bash and zsh theme={"theme":{"light":"github-light","dark":"github-dark"}}
BACH_ACCESS_KEY=TH6C-PLW3-M6SM-KYYW-K86H bach build
```

> [!NOTE]
>
> `BACH_ACCESS_KEY=... bach build` in front of the command is bash syntax. PowerShell and cmd do not understand it and report that the name is not recognised. `bach key > keys.txt` works in every shell, and Bach reads the file even though Windows PowerShell writes it as UTF-16.

You can use a key of your own too, as long as it is 8 to 128 characters of letters, digits and `- _ . ~ + / = :`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.