Docs
SSH ›

Enable ssh

PUT/v1/sandboxes/{id}/ssh

Turns SSH on for the sandbox. Its machine's SSH server is seen to, a port of the public address of the server the sandbox is on is opened to it, and the answer says where to connect. It lets no key in: that is POST /v1/sandboxes/{id}/ssh/keys. The sandbox has to be running. Asked again it changes nothing that is already so, and opens the port if it was not open. From then on the port is closed when the sandbox stops or is moved and opened again by itself when it runs again, at an address GET /v1/sandboxes/{id}/ssh gives.

RequestTypeScript
  1. import { Agental } from "agental-sdk";
  2. const agental = new Agental();
  3. const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
  4. const ssh = await sandbox.ssh.on();
Answer200 OK · SshState
  1. {
  2. "enabled": boolean,
  3. "enabledAt": string | null,
  4. "address": string | null,
  5. "host": string | null,
  6. "port": integer | null,
  7. "user": string | null,
  8. "hostKey": string | null,
  9. }

SSH is on, and this is where to connect.

Path

idrequired
string
e.g. "sbx_0123456789abcdef"

Headers

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

Returns

200 SSH is on, and this is where to connect.

SshState7 fields
enabled
boolean
Whether SSH is turned on for the sandbox.
More It stays so through a stop and a start, and a move to another server: the port is opened again by itself.
enabledAt
stringnull
Since when it is on.
More Null when it is off.
address
stringnull
Where to connect now, as host:port.
More Null while SSH is off, while the sandbox is not running, and in the moments after a start or a move before its port is open again. It is another address after a move, so read it again when a connection is lost.
host
stringnull
The host of address: the public address of the server the sandbox is on.
port
integernull
The port of address, which leads to this sandbox's SSH server and to nothing else.
user
stringnull
Who a key logs in as.
More Null with address.
hostKey
stringnull
The machine's public host key, as a type and the key in base64.
More It comes over this API and not over SSH, so a client can pin it and never be asked to trust one. Null with address.

Errors and other answers

404 Not found.
409 sandbox_not_running, or
409ssh_unavailable the machine has no SSH server and one could not be installed or started in it, or no port could be opened to it, as on a server whose public address nobody has recorded. The message says which.
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.