ssh

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ssh provides transparent SSH authentication support for Git operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSSHCloneURL

func GetSSHCloneURL(httpsURL string) string

GetSSHCloneURL converts HTTPS URLs to SSH URLs for Git hosting providers

func ValidateSSHSetup

func ValidateSSHSetup(ctx context.Context, verbose bool) error

ValidateSSHSetup validates that SSH authentication is working

Types

type AgentAuth

type AgentAuth struct {
	// contains filtered or unexported fields
}

AgentAuth implements SSH agent authentication

func (*AgentAuth) Auth

func (a *AgentAuth) Auth() (ssh.AuthMethod, error)

Auth returns the SSH authentication method for agent auth

func (*AgentAuth) Available

func (a *AgentAuth) Available() bool

Available checks if SSH agent authentication is available

func (*AgentAuth) Name

func (a *AgentAuth) Name() string

Name returns the authentication method name

type AuthMethod

type AuthMethod interface {
	Name() string
	Auth() (ssh.AuthMethod, error)
	Available() bool
}

AuthMethod represents an SSH authentication method

type Authenticator

type Authenticator struct {
	// contains filtered or unexported fields
}

Authenticator manages SSH authentication methods

func NewAuthenticator

func NewAuthenticator(config *Config) (*Authenticator, error)

NewAuthenticator creates a new SSH authenticator with auto-detection

func (*Authenticator) GetAuthMethods

func (a *Authenticator) GetAuthMethods() []ssh.AuthMethod

GetAuthMethods returns all available SSH authentication methods GetAuthMethods returns the available SSH authentication methods

func (*Authenticator) TestConnection

func (a *Authenticator) TestConnection(_ context.Context, host string, port int) error

TestConnection tests SSH connectivity to a host

type Config

type Config struct {
	// SSH agent socket path (auto-detected if not provided)
	AgentSocket string

	// SSH key file paths (auto-detected if not provided)
	KeyFiles []string

	// SSH config file path (defaults to ~/.ssh/config)
	ConfigFile string

	// Host-specific configurations
	HostConfigs map[string]*HostConfig

	// Timeout for SSH operations
	Timeout time.Duration

	// Enable verbose logging
	Verbose bool
}

Config holds SSH configuration and authentication methods

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default SSH configuration

type GitSSHWrapper

type GitSSHWrapper struct {
	// contains filtered or unexported fields
}

GitSSHWrapper provides Git-specific SSH configuration

func NewGitSSHWrapper

func NewGitSSHWrapper(config *Config) (*GitSSHWrapper, error)

NewGitSSHWrapper creates a new Git SSH wrapper

func (*GitSSHWrapper) Cleanup

func (w *GitSSHWrapper) Cleanup() error

Cleanup removes temporary files

func (*GitSSHWrapper) SetupGitSSH

func (w *GitSSHWrapper) SetupGitSSH() error

SetupGitSSH configures Git to use SSH authentication

type HostConfig

type HostConfig struct {
	Hostname     string
	Port         int
	User         string
	IdentityFile string
	ProxyCommand string

	// Additional SSH options
	Options map[string]string
}

HostConfig contains SSH configuration for a specific host

type KeyAuth

type KeyAuth struct {
	// contains filtered or unexported fields
}

KeyAuth implements SSH key file authentication

func (*KeyAuth) Auth

func (a *KeyAuth) Auth() (ssh.AuthMethod, error)

Auth returns the SSH authentication method for key auth

func (*KeyAuth) Available

func (a *KeyAuth) Available() bool

Available checks if the SSH key file is available

func (*KeyAuth) Name

func (a *KeyAuth) Name() string

Name returns the authentication method name

Jump to

Keyboard shortcuts

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