{"modulePath":"github.com/kernel/cli","version":"v0.54.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package ssh\n\nPackage ssh provides SSH connectivity to Kernel browser VMs.\n\n## Functions\n\n```go\nfunc BuildSSHCommand(proxyURL, keyFile string, cfg Config) *exec.Cmd\n```\nBuildSSHCommand constructs the SSH command with websocat ProxyCommand.\n\n```go\nfunc CheckServicesScript() string\n```\nCheckServicesScript returns a script to check if SSH services are already running.\n\n```go\nfunc CheckWebsocatInstalled() error\n```\nCheckWebsocatInstalled verifies websocat is available in PATH. Returns nil if found, error with install instructions if not.\n\n```go\nfunc ExtractVMDomain(cdpURL string) (string, error)\n```\nExtractVMDomain extracts the VM FQDN from a CDP WebSocket URL by decoding the JWT. The CDP URL contains a JWT with the actual Unikraft FQDN in the payload. Example CDP URL: wss://proxy.xxx.dev.onkernel.com:8443/browser/cdp?jwt=eyJ... The JWT payload contains: {\"session\": {\"fqdn\": \"actual-vm-domain.onkernel.app\"}}\n\n```go\nfunc ProxyCommand(proxyURL string) string\n```\nProxyCommand returns the websocat command ssh uses to reach the VM's SSH bridge. The URL is quoted because ssh runs ProxyCommand through a shell.\n\n```go\nfunc ProxyURL(cdpURL string) (string, error)\n```\nProxyURL derives the metro-api SSH WebSocket URL from a CDP WebSocket URL. Both routes share the same metro-api endpoint and session JWT. Example: wss://proxy.xxx.dev.onkernel.com:8443/browser/cdp?jwt=eyJ... becomes  wss://proxy.xxx.dev.onkernel.com:8443/browser/ssh?jwt=eyJ...\n\n```go\nfunc SetupScript(publicKey string) string\n```\nSetupScript generates the bash script to setup SSH services on the VM.\n\n```go\nfunc WriteTempKey(privateKeyPEM string, sessionID string) (string, error)\n```\nWriteTempKey writes the private key to a temporary file and returns the path. The caller is responsible for cleaning up the file.\n\n## Types\n\n```go\ntype BrowserProcessService interface {\n\tExec(ctx context.Context, id string, body kernel.BrowserProcessExecParams, opts ...interface{}) (*kernel.BrowserProcessExecResponse, error)\n}\n```\nBrowserProcessService defines the interface for executing commands on the VM. This matches the kernel SDK's BrowserProcessService.\n\n```go\ntype Config struct {\n\tBrowserID     string\n\tIdentityFile  string // empty = generate ephemeral\n\tLocalForward  string // -L flag value\n\tRemoteForward string // -R flag value\n\tSetupOnly     bool\n\tOutput        string // \"json\" for machine-readable output\n}\n```\nConfig holds SSH connection configuration\n\n```go\ntype KeyPair struct {\n\tPrivateKeyPEM    string // PEM-encoded private key (OpenSSH format)\n\tPublicKeyOpenSSH string // OpenSSH authorized_keys format\n}\n```\nKeyPair holds an SSH keypair\n\n```go\nfunc GenerateKeyPair() (*KeyPair, error)\n```\nGenerateKeyPair creates an ed25519 SSH keypair suitable for OpenSSH. Returns the private key in PEM format and public key in authorized\\_keys format.\n\n","path":"github.com/kernel/cli/pkg/ssh","name":"ssh","synopsis":"Package ssh provides SSH connectivity to Kernel browser VMs.","isRedistributable":true}
