Skip to content

sshconfig

import "github.com/ananth/codespace-zed/internal/sshconfig"

Package sshconfig manages the local SSH configuration for codespace connections. It writes per-codespace config files into \~/.ssh/codespaces-zed/ and ensures the main \~/.ssh/config includes them.

Index

Constants

const SSHIncludeLine = "Include ~/.ssh/codespaces-zed/*.conf"

func EnsureConfigIncludesGenerated

func EnsureConfigIncludesGenerated(mainConfigPath string) error

EnsureConfigIncludesGenerated ensures the main SSH config includes the generated configs.

func EnsureIncludeLine

func EnsureIncludeLine(configText string) string

EnsureIncludeLine ensures the SSH include line is at the top of the config. It removes any existing copy and prepends it.

func ParsePrimaryHostAlias

func ParsePrimaryHostAlias(sshConfig string) (string, error)

ParsePrimaryHostAlias extracts the first concrete Host entry from SSH config text.

func ReadExistingAlias

func ReadExistingAlias(includeDir, codespaceName string) (string, bool)

ReadExistingAlias reads the SSH alias from an existing codespace config file. Returns the alias and true if the file exists and contains a valid Host entry, or empty string and false otherwise.

func WriteCodespaceConfig

func WriteCodespaceConfig(includeDir, codespaceName, content string) error

WriteCodespaceConfig writes the SSH config for a specific codespace.

type SSHPaths

SSHPaths holds the resolved SSH directory paths.

type SSHPaths struct {
    MainConfigPath string
    IncludeDir     string
}

func ResolvePaths

func ResolvePaths() SSHPaths

ResolvePaths returns the SSH paths for the current platform.

func (SSHPaths) CodespaceConfigPath

func (p SSHPaths) CodespaceConfigPath(codespaceName string) string

CodespaceConfigPath returns the path for a codespace-specific SSH config.

Generated by gomarkdoc