Add template ssh key
/v1/templates/{id}/ssh/keysLets 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.
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const template = await agental.templates.get("tpl_0123456789abcdef");
- const key = await template.addSshKey(publicKey);
- {
- "id": string,
- "fingerprint": string,
- "type": string,
- "comment": string | null,
- }
The key is let in to the sandboxes made from the template from now on.
Path
idrequiredstring | e.g. "tpl_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Body
publicKeyrequiredstring | |
codestring | 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.
idfingerprinttypecommentMore
Null when nothing does.Errors and other answers
| 400 | invalid_request publicKey is not one OpenSSH public key line. |
| 400 | code_required a person signed in, with two-factor sign-in on, sent no code for a key new to the template. |
| 400 | invalid_code the code is not right. |
| 400 | code_used six digits from the app that were used already. |
| 403 | key_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. |
| 409 | too_many_ssh_keys the template lets in 50 keys already. Nothing was added. |
| 429 | rate_limited five wrong codes for the account in a quarter of an hour, on this call or another that asks for one. |
| 501 | ssh_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.