SSH
Accessor: client.SSH()
Create and manage SSH sessions for sandboxes. Supports direct SSH access and TCP tunneling through SSH connections.
CreateSession
Section titled “CreateSession”Create a new SSH session for a sandbox. Returns connection details including host, port, and authentication credentials.
session, err := client.SSH().CreateSession(ctx, "default", "sandbox-123")if err != nil { log.Fatal(err)}fmt.Printf("SSH via %s://%s:%d\n", session.GatewayScheme, session.GatewayHost, session.GatewayPort)RevokeSession
Section titled “RevokeSession”Revoke an active SSH session, immediately terminating any connections using it.
deletion, err := client.SSH().RevokeSession(ctx, "default", session.Token)if err != nil { log.Fatal(err)}if deletion.Outcome == v1.DeletionCompleted { fmt.Println("Session revoked")}Tunnel
Section titled “Tunnel”Create an SSH tunnel that provides a bidirectional stream to a port inside a
sandbox. This combines SSH session creation with TCP forwarding into a single
operation, returning an io.ReadWriteCloser for the tunnel.
tunnel, err := client.SSH().Tunnel(ctx, "default", "my-sandbox", 8080)if err != nil { log.Fatal(err)}defer tunnel.Close()
// Use the tunnel as a regular io.ReadWriteCloser_, err = tunnel.Write([]byte("GET / HTTP/1.0\r\n\r\n"))if err != nil { log.Fatal(err)}See also: TCP Forwarding, Error Handling
We are a Cloud Native Computing Foundation sandbox project.
Copyright OpenShell a Series of LF Projects, LLC
For website terms of use, trademark policy and other project policies please see lfprojects.org/policies/.