Skip to content

SSH

SSH endpoints let you create and manage SSH access credentials for a sandbox. Generate credentials, validate them, regenerate them, or revoke access entirely.

Generate SSH credentials for a sandbox. Returns an id to use as the SSH username, a password, and the SSH command to connect.

from leap0 import Leap0Client
client = Leap0Client()
sandbox = client.sandboxes.create()
access = sandbox.ssh.create_access()
print("SSH username:", access.id)
print(access.ssh_command)
print("Password:", access.password)
{
"id": "ssh-bb961077616ff86f",
"sandbox_id": "sbx-abc123",
"password": "a1b2c3d4e5f6...",
"expires_at": "2025-03-06T17:00:00Z",
"created_at": "2025-03-06T16:00:00Z",
"updated_at": "2025-03-06T16:00:00Z",
"ssh_command": "ssh -o StrictHostKeyChecking=accept-new ssh-bb961077616ff86f@sbx-abc123.${env.LEAP0_SANDBOX_DOMAIN}"
}

Check whether an SSH access credential is still valid and not expired.

from leap0 import Leap0Client
client = Leap0Client()
sandbox = client.sandboxes.create()
validation = sandbox.ssh.validate_access(
access_id="<ssh-id>",
password="<ssh-password>",
)
print("Valid:", validation.valid)
print("Sandbox:", validation.sandbox_id)

Invalidate the current credential and generate a new one. The expiry is also reset.

from leap0 import Leap0Client
client = Leap0Client()
sandbox = client.sandboxes.create()
access = sandbox.ssh.regenerate_access()
print("New password:", access.password)

Revoke SSH access for a sandbox. The credential is invalidated immediately.

from leap0 import Leap0Client
client = Leap0Client()
sandbox = client.sandboxes.create()
sandbox.ssh.delete_access()