Docs
SSH ›

Add ssh key

POST/v1/sandboxes/{id}/ssh/keys

Lets a public key log in to the sandbox as root. It opens nothing and starts nothing: whether the sandbox can be reached is PUT /v1/sandboxes/{id}/ssh. A key that is already let in is not added twice, and the answer is the same. The sandbox has to be running. A fork has its source's keys, and a roll-back puts back the ones the snapshot had.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
  4. const key = await sandbox.ssh.addKey(publicKey);
Answer201 Created · SshKey
  1. {
  2. "id": string,
  3. "fingerprint": string,
  4. "type": string,
  5. "comment": string | null,
  6. }

The key may log in.

Path

idrequired
string
e.g. "sbx_0123456789abcdef"

Headers

Authorizationrequired
Bearer key
An API key that may make this call.

Body

publicKeyrequired
string

Returns

201 The key may log in.

SshKey4 fields
id
string
What the key is named by when it is removed: the SHA-256 of the key, written so that it can stand in a path.
fingerprint
string
The same, as ssh-keygen -l prints it.
type
string
comment
stringnull
What follows the key on its line.
More Null when nothing does.

Errors and other answers

400invalid_request publicKey is not one OpenSSH public key line.
404 Not found.
409 sandbox_not_running.
501ssh_endpoint_not_configured sandboxes here are not logged in to over SSH. GET /v1/policy says so as ssh.

Every error answers { "error": { "code", "message" } }; a key without the action a call needs answers 403 key_action_forbidden, naming it.