ssh

package
v0.14.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ssh provides SSH connectivity to Kernel browser VMs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildSSHCommand

func BuildSSHCommand(vmDomain, keyFile string, cfg Config) *exec.Cmd

BuildSSHCommand constructs the SSH command with websocat ProxyCommand.

func CheckServicesScript

func CheckServicesScript() string

CheckServicesScript returns a script to check if SSH services are already running.

func CheckWebsocatInstalled

func CheckWebsocatInstalled() error

CheckWebsocatInstalled verifies websocat is available in PATH. Returns nil if found, error with install instructions if not.

func ExtractVMDomain

func ExtractVMDomain(cdpURL string) (string, error)

ExtractVMDomain 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"}}

func SetupScript

func SetupScript(publicKey string) string

SetupScript generates the bash script to setup SSH services on the VM.

func WriteTempKey

func WriteTempKey(privateKeyPEM string, sessionID string) (string, error)

WriteTempKey writes the private key to a temporary file and returns the path. The caller is responsible for cleaning up the file.

Types

type BrowserProcessService

type BrowserProcessService interface {
	Exec(ctx context.Context, id string, body kernel.BrowserProcessExecParams, opts ...interface{}) (*kernel.BrowserProcessExecResponse, error)
}

BrowserProcessService defines the interface for executing commands on the VM. This matches the kernel SDK's BrowserProcessService.

type Config

type Config struct {
	BrowserID     string
	IdentityFile  string // empty = generate ephemeral
	LocalForward  string // -L flag value
	RemoteForward string // -R flag value
	SetupOnly     bool
}

Config holds SSH connection configuration

type KeyPair

type KeyPair struct {
	PrivateKeyPEM    string // PEM-encoded private key (OpenSSH format)
	PublicKeyOpenSSH string // OpenSSH authorized_keys format
}

KeyPair holds an SSH keypair

func GenerateKeyPair

func GenerateKeyPair() (*KeyPair, error)

GenerateKeyPair creates an ed25519 SSH keypair suitable for OpenSSH. Returns the private key in PEM format and public key in authorized_keys format.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL