Sandbox
SSH()
| Type | Description |
|---|---|
*SSH | SSH client and server helpers |
SSH
Connect()
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | Cancels the connection attempt |
| opts | ...SSHClientOption | Client options |
| Type | Description |
|---|---|
*SSHClient | Native SSH client session |
error | Typed microsandbox error |
Server()
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | Cancels server preparation |
| opts | ...SSHServerOption | Server options |
| Type | Description |
|---|---|
*SSHServer | Server endpoint |
error | Typed microsandbox error |
SSHClient
Exec()
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | Cancels the exec request |
| command | string | Command string sent through SSH |
| opts | ...SSHExecOption | Exec options |
| Type | Description |
|---|---|
*SSHOutput | Captured output and status |
error | Typed microsandbox error |
Attach()
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | Cancels the attach session |
| opts | ...SSHAttachOption | Attach options |
| Type | Description |
|---|---|
int | Exit code |
error | Typed microsandbox error |
SFTP()
| Type | Description |
|---|---|
*SFTPClient | SFTP client session |
error | Typed microsandbox error |
Close()
SFTPClient
| Method | Returns | Description |
|---|---|---|
| Read(ctx, path) | ([]byte, error) | Read a file into memory |
| Write(ctx, path, data) | error | Create or truncate a file |
| Mkdir(ctx, path) | error | Create a directory |
| RemoveFile(ctx, path) | error | Remove a file |
| RemoveDir(ctx, path) | error | Remove an empty directory |
| Rename(ctx, oldPath, newPath) | error | Rename a file or directory |
| RealPath(ctx, path) | (string, error) | Resolve a canonical path |
| ReadLink(ctx, path) | (string, error) | Read a symlink target |
| Symlink(ctx, target, linkPath) | error | Create a symlink |
| Close(ctx) | error | Close the SFTP session |
SSHServer
ServeStdio()
Close()
Types
SSHOutput
| Field / Method | Type | Description |
|---|---|---|
| Status | int | Exit status code |
| Stdout | []byte | Captured stdout bytes |
| Stderr | []byte | Captured stderr bytes |
| Success() | bool | true if status is 0 |
SSHClientOption
| Option | Description |
|---|---|
| WithSSHUser(user) | SSH login user. Defaults to root |
| WithSSHTerm(term) | Terminal name for interactive sessions |
| WithSSHClientSFTP(enabled) | Enable or disable SFTP on the internal server |
SSHExecOption
| Option | Description |
|---|---|
| WithSSHTTY(enabled) | Request a PTY for the exec channel |
SSHAttachOption
| Option | Description |
|---|---|
| WithSSHAttachTerm(term) | Terminal name for the shell |
| WithSSHDetachKeys(keys) | Detach key sequence |
SSHServerOption
| Option | Description |
|---|---|
| WithSSHHostKeyPath(path) | Override the host private key path |
| WithSSHAuthorizedKeysPath(path) | Override the authorized-keys path |
| WithSSHServerUser(user) | Override the guest user used for exec requests |
| WithSSHServerSFTP(enabled) | Enable or disable SFTP |