Detach an SSH key

Remove the key from the root user's authorized_keys on running servers in this zone. We remove it in the background. Each server records ssh_key_detached or ssh_key_detach_failed in its events. The key leaves the server's ssh_keys once it's removed from the server. Detaching a key twice is safe.

POST https://{availability_zone}.betterstackcloud.com/v1/ssh-keys/{slug}/detach
slug string required

The slug of the key. Dots are part of the slug.

team_id string

The ID of the team that owns the key. Send it when more than one of your teams has a key with this slug.

Authorization string required

Bearer $TOKEN

Content-Type string

application/json

server_ids array of strings

The IDs of the servers to detach the key from. When one of them doesn't exist or can't change now, the request is refused and nothing changes. A repeated ID counts once.

all boolean

Whether to detach the key from every server in this zone that has it. A server that can't change now is skipped and listed with a reason. Send either all or server_ids, never both.

202 Accepted
{
  "servers": {
    "queued": [
      "example"
    ],
    "skipped": [
      {
        "server_id": "123456789",
        "reason": "kubernetes_managed"
      }
    ]
  }
}

Returns the SSH key.

servers object

What we did with each server.

servers.queued array of strings

The IDs of the servers we're changing.

servers.skipped array of objects

The servers we skipped with all, each with a reason, empty when you send server_ids.

servers.skipped[].server_id string

The ID of the skipped server.

servers.skipped[].reason string

Why we skipped the server.
Valid values:
kubernetes_managed: The server is a Kubernetes worker node.
locked: The server is locked.
server_not_running: The server isn't running.