# dokploy_ssh_key (Data Source)

Looks up an SSH key that already exists in Dokploy (Settings > SSH Keys), so that a server or a private git source can reference it by name:

```terraform
data "dokploy_ssh_key" "deploy" {
  name = "deploy"
}

resource "dokploy_server" "worker" {
  ssh_key_id = data.dokploy_ssh_key.deploy.id
  # ...
}
```

~> **The data source does not expose the private key.** `private_key` exists on the `dokploy_ssh_key` resource, but not here, by design. A consumer needs only the id.

~> Dokploy does not enforce name uniqueness. If two keys share a name, this data source fails instead of a guess. Look the record up by `id` in that case.

## Example Usage

```terraform
# Look up an SSH key that already exists in Dokploy, by name.
data "dokploy_ssh_key" "deploy" {
  name = "deploy"
}

# Or by id, when the name is ambiguous or you already hold the id.
data "dokploy_ssh_key" "by_id" {
  id = "UvJz8naQ2Q1G26LblagBS"
}

# The usual purpose of a lookup: a key that exists once and that several
# servers or private git sources reference.
resource "dokploy_server" "worker" {
  name       = "worker-1"
  ip_address = "203.0.113.10"
  ssh_key_id = data.dokploy_ssh_key.deploy.id
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `id` (String) SSH key id. Set it for a lookup by id, or leave it unset and set `name`.
- `name` (String) Display name as shown in Dokploy. Set exactly one of `id` or `name`.

### Read-Only

- `created_at` (String) Creation timestamp from the server.
- `description` (String) Free-text description, or null.
- `organization_id` (String) Id of the organization that owns the key.
- `public_key` (String) Public key in OpenSSH format.