# Authentication Commands

> Authenticate the CLI with your Aerostack account and link local projects to a workspace. Required before deploying or managing secrets.

Commands for authenticating with Aerostack and linking local projects.

## aerostack login

Authenticate with your Aerostack account using your API key.

```bash
aerostack login
```

The CLI prompts for your API key. Find it at [app.aerostack.dev/account/keys](https://app.aerostack.dev/account/keys).

**Using an environment variable:**

```bash

aerostack login
```

**Key types:**

| Type | Access level |
|------|-------------|
| Account key | Full access — can create/deploy any project in your account |
| Project key | Scoped to a single project |

---

## aerostack link

Link a local directory to an existing Aerostack project by its project ID.

```bash
aerostack link [project-id]
```

Find your project ID in the Aerostack dashboard under **Project Settings**.

```bash
aerostack link proj_abc123
```

Once linked, `aerostack deploy` targets that project automatically.

---

## aerostack whoami

Show your current authentication and linked project status.

```bash
aerostack whoami
```

Output:

```
Logged in as: john@example.com (account key)
Linked project: my-backend (proj_abc123)
Linked directory: /Users/john/projects/my-backend
```

---

## aerostack auth doctor

Diagnose authentication configuration issues in your project.

```bash
aerostack auth doctor
```

Uses the AI agent to analyze your auth setup and suggest fixes. Requires `aerostack index` to have been run first.

Run `aerostack auth doctor` when users report login or token issues. It checks your auth route configuration, OTP setup, and JWT settings.

---

## aerostack uninstall

Remove the CLI and all associated data.

```bash
aerostack uninstall

# Skip confirmation
aerostack uninstall --force
```
