Sandbox
sb.ssh()
Example
Example
open_client() or prepare_server(). This method is synchronous; the helpers it returns are async.
Returns
SSH namespace for this sandbox.
SandboxSshOps
Returned by sb.ssh()
SSH operations for a sandbox.ssh.open_client()
Example
Example
Parameters
userstrSSH login user. Default
“root”.termstr | NoneTerminal name for interactive sessions. Defaults to
$TERM.sftpboolEnable or disable SFTP on the internal server. Default
True.inactivity_timeoutfloat | NoneDisconnect after this many seconds without SSH traffic.
0 disables the timeout; None inherits the global setting.Returns
Connected SSH client session.
ssh.prepare_server()
Example
Example
SshServer serves one connection over this process’s stdin/stdout.
Parameters
host_key_pathstr | os.PathLike[str] | NoneOverride the host private key path.
authorized_keys_pathstr | os.PathLike[str] | NoneOverride the authorized-keys path.
userstr | NoneOverride the guest user used for exec requests.
sftpboolEnable or disable SFTP. Default
True.inactivity_timeoutfloat | NoneDisconnect after this many seconds without SSH traffic.
0 disables the timeout; None inherits the global setting.Returns
Reusable SSH server endpoint.
SshClient
Returned by ssh.open_client()
Native in-process SSH client session. A connected, native in-process SSH client session, obtained fromssh.open_client().
client.exec()
Example
Example
tty=True a PTY is allocated and stderr is folded into stdout.
Parameters
commandstrCommand string sent through SSH.
ttyboolRequest a PTY for the exec channel. Default
False.Returns
Captured output and exit status.
client.attach()
Example
Example
Parameters
termstr | NoneTerminal name for the shell. Defaults to
$TERM.detach_keysstr | NoneDetach key sequence, e.g.
“ctrl-p,ctrl-q”.Returns
int
Shell exit code (128 if terminated by signal).
client.sftp()
Example
Example
sftp subsystem and returns a high-level session for reading, writing, and listing files inside the guest.
Returns
SFTP client session.
client.close()
Example
Example
SshServer
Returned by ssh.prepare_server()
Reusable SSH server endpoint for a sandbox. A reusable SSH server endpoint for a sandbox, obtained fromssh.prepare_server().
server.serve_connection()
Example
Example
server.close()
Example
Example
SftpClient
Returned by client.sftp()
High-level SFTP client session over an SSH connection. All methods are async.sftp.read()
Returns
bytes
sftp.write()
sftp.mkdir()
sftp.remove_file()
sftp.remove_dir()
sftp.rename()
sftp.real_path()
Returns
str
sftp.read_link()
Returns
str
sftp.symlink()
sftp.close()
Types
SshOutput
Returned by client.exec()
Output from an SSH exec request.