SSH ›
Enable ssh
PUT
/v1/sandboxes/{id}/sshTurns 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
- import { Agental } from "agental-sdk";
- const agental = new Agental();
- const sandbox = await agental.sandboxes.get("sbx_2a9a47e50daec64a");
- const ssh = await sandbox.ssh.on();
Answer200 OK · SshState
- {
- "enabled": boolean,
- "enabledAt": string | null,
- "address": string | null,
- "host": string | null,
- "port": integer | null,
- "user": string | null,
- "hostKey": string | null,
- }
SSH is on, and this is where to connect.
Path
idrequiredstring | e.g. "sbx_0123456789abcdef" |
Headers
AuthorizationrequiredBearer key | An API key that may make this call. |
Returns
200 SSH is on, and this is where to connect.
SshState7 fields
enabledboolean
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.enabledAtstringnull
Since when it is on.
More
Null when it is off.addressstringnull
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.hoststringnull
The host of address: the public address of the server the sandbox is on.
portintegernull
The port of address, which leads to this sandbox's SSH server and to nothing else.
userstringnull
Who a key logs in as.
More
Null with address.hostKeystringnull
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 |
| 409 | ssh_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. |
| 501 | ssh_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.