Docs
SSH ›

Add template ssh key

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

Lets a public key log in as root to every sandbox made from the template from now on: it is written to the machine's authorized keys file as the sandbox is made, before the create answers. It opens nothing: that is PUT /v1/templates/{id}/ssh. A sandbox already made is not changed: POST /v1/sandboxes/{id}/ssh/keys lets a key in to one. A key that is already let in is not added twice, and the answer is the same. At most 50. While the account has two-factor sign-in on, a person signed in sends a code with a key new to the template.

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

The key is let in to the sandboxes made from the template from now on.

Path

idrequired
string
e.g. "tpl_0123456789abcdef"

Headers

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

Body

publicKeyrequired
string
code
string
For a person signed in to the site whose account has two-factor sign-in on, and a key the template does not let in yet: the six digits the authenticator app shows now, or one of the backup codes, which is then used up. Every sandbox made from the template from now on lets the key in as root, with the template's secrets, so a session taken from a browser does not let one in alone. A call made with an API key needs none, and its code is not read. e.g. "482913"

Returns

201 The key is let in to the sandboxes made from the template from now on.

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.
400code_required a person signed in, with two-factor sign-in on, sent no code for a key new to the template.
400invalid_code the code is not right.
400code_used six digits from the app that were used already.
403key_action_forbidden the key does not take the action ssh, or it is limited to some sandboxes and not to this template. Nothing was changed.
404 Not found.
409too_many_ssh_keys the template lets in 50 keys already. Nothing was added.
429rate_limited five wrong codes for the account in a quarter of an hour, on this call or another that asks for one.
501ssh_endpoint_not_configured sandboxes here are not logged in to over SSH. GET /v1/policy says so as ssh. Nothing was changed.

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