# SSHKey

> For the complete documentation index, see [llms.txt](https://docs-stg.ringleader.dev/llms.txt).


> Forward a local private key into workstations as an ambient ssh-agent, so processes on the workstation can authenticate outbound.


An **SSHKey** makes one of *your* local private keys available **inside** selected
workstations, as a forwarded ssh-agent, never as a file on the workstation.
[SSH keys for outbound Git](https://docs-stg.ringleader.dev/workstations/connectivity/git-ssh-keys/)
explains how it works, what it costs, and how to forward a key.

```text
apiVersion: workstations.ringleader.dev/v1
kind: SSHKey
```

## Selection

An SSHKey attaches to a workstation you own when its `selector.matchLabels` are a subset of
the workstation's labels. An **empty or absent selector matches every workstation you own** (an
unconditional key).

An SSHKey is a **device-local** kind. It never mirrors or routes to another origin, and it only
ever forwards *from the device that declares it*.

## Spec fields

| Field | Type | Description |
|-------|------|-------------|
| `path` | `string` | **Required.** Path to the local **private** key on this device. A leading `~` expands to your home directory. With `source: agent`, the daemon reads `<path>.pub` instead. |
| `source` | `string` | `file` (the default): the daemon reads the key file and holds the key. `agent`: the key stays in your ssh-agent, which signs each request. |
| `selector.matchLabels` | `map` | Which workstations receive the forwarded key. Empty/absent matches every workstation you own. |
| `enabled` | `bool` | Master on/off switch (default `true`; an absent field reads as enabled). When `false`, the key is not forwarded into any workstation, even one its selector matches. Selection still records the match, but forwarding is paused. |

## Create a key from the command line

`rl sshkey create` builds an SSHKey from flags and applies it:

```bash
rl sshkey create github --path ~/.ssh/id_ed25519
rl sshkey create github --path ~/.ssh/id_ed25519 --dry-run -o yaml   # print, don't apply
```

With `--source agent`, it prints a note if it cannot read `<path>.pub`.

| Flag | Description |
|------|-------------|
| `--path <path>` | **Required.** Path to the private key. With `--source agent`, the daemon reads `<path>.pub`. |
| `--source <source>` | `file` (default) or `agent`. |
| `--dry-run` | Print the generated object instead of applying it. |
| `-o, --output <format>` | `yaml` (default) or `json`. Prints the object and creates nothing. |
| `-n, --namespace <ns>` | Namespace. |
| `--as <subject>` | Impersonate a subject. |
| `--home <dir>` | Data directory. |

## Enable or disable a key

Flip the `enabled` toggle from the command line without editing the file, by
name, or across every matching key with a label selector:

```bash
rl sshkey enable github
rl sshkey disable github
rl sshkey disable -l tier=dev     # every matching key
```

| Flag | Description |
|------|-------------|
| `-l, --selector <selector>` | Label selector (`key=value[,key!=value,key in (a,b),key,!key]`) instead of a name. |
| `-n, --namespace <ns>` | Namespace. |
| `--as <subject>` | Impersonate a subject. |
| `--home <dir>` | Data directory. |

## Status

None. An SSHKey has no `status`: it is a device-local selection rule the daemon
acts on directly.

