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. The idle SSH helper does not start a sandbox or take ownership of shutdown. Creating a client or prepared server endpoint starts or connects to the sandbox and keeps using that run. Commands and SFTP on that endpoint reuse the same run. After you release the original sandbox handles, the helper returns an error. Explicit stop can interrupt active sessions.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 | timedelta | 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 | timedelta | 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. Known SSH signals return
128 + the Linux signal number (for example, 143 for TERM); unknown signal names return 128.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.