Skip to content

Commit

Permalink
feat(config): make advanced SSH options configurable (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
adb-sh authored Nov 6, 2024
1 parent 9e15cd3 commit 732f57d
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions pkg/sshx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ import (

// Config is a flat configuration for an SSH connection.
type Config struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
KeyFile string `yaml:"key-file"`
Key string `yaml:"key"`
Passphrase string `yaml:"passphrase"`
Fingerprint string `yaml:"fingerprint"`
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
Password string `yaml:"password"`
KeyFile string `yaml:"key-file"`
Key string `yaml:"key"`
Passphrase string `yaml:"passphrase"`
Fingerprint string `yaml:"fingerprint"`
HostKeyAlgorithms []string `yaml:"host-key-algorithms"`
KeyExchanges []string `yaml:"key-exchanges"`
Ciphers []string `yaml:"ciphers"`
MACs []string `yaml:"macs"`
}

// Client is an augmented SSH client.
Expand Down Expand Up @@ -155,11 +159,19 @@ func (client *Client) normalizeConfig(config *Config) (*ssh.ClientConfig, error)
hostKeyCallback = ssh.InsecureIgnoreHostKey()
}

var connConfig = ssh.Config{
KeyExchanges: config.KeyExchanges,
Ciphers: config.Ciphers,
MACs: config.MACs,
}

return &ssh.ClientConfig{
Auth: []ssh.AuthMethod{authMethod},
HostKeyCallback: hostKeyCallback,
User: config.User,
Timeout: client.Timeout,
Auth: []ssh.AuthMethod{authMethod},
HostKeyCallback: hostKeyCallback,
User: config.User,
Timeout: client.Timeout,
HostKeyAlgorithms: config.HostKeyAlgorithms,
Config: connConfig,
}, nil
}

Expand Down

0 comments on commit 732f57d

Please sign in to comment.