Skip to content

SshClient

Source: leap0/_sync/ssh.py

SshClient(transport: Transport)

Manage SSH access credentials for a sandbox.

Each sandbox supports a single set of SSH credentials at a time. Creating access when credentials already exist returns 409 Conflict. Use :meth:regenerate_access to rotate credentials without revoking first.

Example:

sandbox = client.sandboxes.create()
access = sandbox.ssh.create_access()
print(access.command)

Attributes: None.

create_access(sandbox: SandboxRef, http_timeout: float | None = None) -> SshAccess

Generate SSH credentials for a sandbox.

Returns an access ID (used as the SSH username), a password, and the full SSH command to connect.

Args: sandbox: Sandbox ID or object. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: SshAccess: Generated SSH credential bundle.

delete_access(sandbox: SandboxRef, http_timeout: float | None = None) -> None

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

Args: sandbox: Sandbox ID or object. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

validate_access(sandbox: SandboxRef, *, access_id: str, password: str, http_timeout: float | None = None) -> SshValidation

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

Args: sandbox: Sandbox ID or object. access_id: SSH access identifier. password: SSH password. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: SshValidation: Validation result for the supplied credential pair.

regenerate_access(sandbox: SandboxRef, http_timeout: float | None = None) -> SshAccess

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

Args: sandbox: Sandbox ID or object. http_timeout: Optional HTTP request timeout in seconds for this SDK call.

Returns: SshAccess: Newly generated SSH credential bundle.