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

# nanny auth

> Log in to Nanny Cloud, or log out. Enforcement stays fully local either way.

`nanny auth` logs you in to [Nanny Cloud](https://nanny.run/cloud) so `nanny run` can sync its event log to your dashboard. It's optional — enforcement is always local and never depends on it.

Sync is automatic once a machine is logged in, no config field to set. See [Connect to Nanny Cloud](/v0.5/guides/managed-mode) for the full flow.

```bash theme={null}
nanny auth <COMMAND>
```

***

## Commands

### login

Log in by approving in your browser.

```bash theme={null}
nanny auth login [--env <env>]
```

Approve in the browser and you're connected. `nanny run` starts syncing automatically, no config change needed.

#### Flags

| Flag      | Type                         | Default | Description                                                                                                               |
| --------- | ---------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------- |
| `--env`   | `dev` \| `staging` \| `prod` | `prod`  | Which Nanny Cloud to log in to. `dev`/`staging` are for Nanny's own testing. Accepts `--env staging` or `--env=staging`.  |
| `--token` | flag                         | —       | Log in without a browser, for CI and headless machines. Reads an API key from `NANNY_API_KEY` or stdin. Requires `--env`. |

#### CI and headless machines

A browser flow needs a person. For CI, log in with an API key instead — supplied through `NANNY_API_KEY` or stdin, never a command argument:

```bash theme={null}
NANNY_API_KEY="nny_..." nanny auth login --token --env prod
# or pipe it:
echo "$NANNY_API_KEY" | nanny auth login --token --env staging
```

`--env` is required so it targets the right cloud.

***

### logout

Log out and stop syncing.

```bash theme={null}
nanny auth logout
```

Enforcement is unaffected. To revoke the key everywhere, use the dashboard.

***

## Skip sync for one run

To forward nothing for a single run without logging out, pass `--no-sync` to `nanny run`:

```bash theme={null}
nanny run --no-sync
```
