Sandbox
sb.SSH()
Example
Example
Returns
SSH client and server helpers for this sandbox.
SandboxSSHOps
Returned by SSH()
SSH operations namespace for a sandbox. Obtained viasb.SSH(). Holds no resources; it groups the client and server entry points.
ssh.OpenClient()
Example
Example
root, terminal from $TERM (falling back to xterm), and SFTP enabled.
Parameters
ctxcontext.ContextCancels the connection attempt.
opts…SSHClientOptionLogin user, terminal name, SFTP toggle, and inactivity timeout.
Returns
Native SSH client session.
error
Typed microsandbox error.
ssh.PrepareServer()
Example
Example
SSHServer can serve connections one at a time over the process’s standard streams.
Parameters
ctxcontext.ContextCancels server preparation.
opts…SSHServerOptionHost key, authorized keys, guest user, SFTP toggle, and inactivity timeout.
Returns
Prepared server endpoint.
error
Typed microsandbox error.
SSHClient
Returned by OpenClient()
A native in-process SSH client session. Obtained viaOpenClient().
c.Exec()
Example
Example
WithSSHTTY is passed.
Parameters
ctxcontext.ContextCancels the exec request.
commandstringCommand string sent through SSH.
opts…SSHExecOptionPTY toggle for the exec channel.
Returns
Captured stdout, stderr, and exit status.
error
Typed microsandbox error.
c.Attach()
Example
Example
Parameters
ctxcontext.ContextCancels the attach session.
opts…SSHAttachOptionTerminal name and detach key sequence.
Returns
int
Shell exit code (128 if terminated by signal).
error
Typed microsandbox error.
c.SFTP()
Example
Example
Parameters
ctxcontext.ContextCancels opening the SFTP session.
Returns
SFTP client session.
error
Typed microsandbox error.
c.Close()
Example
Example
Parameters
ctxcontext.ContextCancels the close.
Returns
error
Typed microsandbox error.
SSHServer
Returned by PrepareServer()
A prepared SSH server endpoint for a sandbox. Obtained viaPrepareServer().
srv.ServeConnection()
Example
Example
SSHServer to serve another connection.
Parameters
ctxcontext.ContextCancels serving the connection.
Returns
error
Typed microsandbox error.
srv.Close()
Example
Example
Parameters
ctxcontext.ContextCancels the close.
Returns
error
Typed microsandbox error.
SSHOutput
Returned by Exec()
The output from an SSH exec request.o.Status
int
Exit status code
o.Stdout
[]byte
Captured stdout bytes
o.Stderr
[]byte
Captured stderr bytes
o.Success()
Example
Example
0.
Returns
bool
true when Status is 0.SFTPClient
Returned by SFTP()
A high-level SFTP client session over an SSH connection. Obtained viaSFTP().
sftp.Read()
Returns
([]byte, error)
sftp.Write()
Returns
error
sftp.Mkdir()
Returns
error
sftp.RemoveFile()
Returns
error
sftp.RemoveDir()
Returns
error
sftp.Rename()
Returns
error
sftp.RealPath()
Returns
(string, error)
sftp.ReadLink()
Returns
(string, error)
sftp.Symlink()
Returns
error
sftp.Close()
Returns
error
Types
SSHClientOption
Used by OpenClient()
Functional option forOpenClient(). Defaults: user root, terminal from $TERM (falling back to xterm), SFTP enabled, and the global SSH inactivity timeout.
SSHExecOption
Used by Exec()
Functional option forExec().
SSHAttachOption
Used by Attach()
Functional option forAttach(). The default terminal comes from $TERM (falling back to xterm); detach keys default to the standard sequence.
SSHServerOption
Used by PrepareServer()
Functional option forPrepareServer(). SFTP is enabled by default, the inactivity timeout inherits the global SSH setting, and the default authorized-keys file is loaded when no path is provided.