Skip to content

Commit 732f57d

Browse files
authored
feat(config): make advanced SSH options configurable (#58)
1 parent 9e15cd3 commit 732f57d

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

pkg/sshx/client.go

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ import (
1313

1414
// Config is a flat configuration for an SSH connection.
1515
type Config struct {
16-
Host string `yaml:"host"`
17-
Port int `yaml:"port"`
18-
User string `yaml:"user"`
19-
Password string `yaml:"password"`
20-
KeyFile string `yaml:"key-file"`
21-
Key string `yaml:"key"`
22-
Passphrase string `yaml:"passphrase"`
23-
Fingerprint string `yaml:"fingerprint"`
16+
Host string `yaml:"host"`
17+
Port int `yaml:"port"`
18+
User string `yaml:"user"`
19+
Password string `yaml:"password"`
20+
KeyFile string `yaml:"key-file"`
21+
Key string `yaml:"key"`
22+
Passphrase string `yaml:"passphrase"`
23+
Fingerprint string `yaml:"fingerprint"`
24+
HostKeyAlgorithms []string `yaml:"host-key-algorithms"`
25+
KeyExchanges []string `yaml:"key-exchanges"`
26+
Ciphers []string `yaml:"ciphers"`
27+
MACs []string `yaml:"macs"`
2428
}
2529

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

162+
var connConfig = ssh.Config{
163+
KeyExchanges: config.KeyExchanges,
164+
Ciphers: config.Ciphers,
165+
MACs: config.MACs,
166+
}
167+
158168
return &ssh.ClientConfig{
159-
Auth: []ssh.AuthMethod{authMethod},
160-
HostKeyCallback: hostKeyCallback,
161-
User: config.User,
162-
Timeout: client.Timeout,
169+
Auth: []ssh.AuthMethod{authMethod},
170+
HostKeyCallback: hostKeyCallback,
171+
User: config.User,
172+
Timeout: client.Timeout,
173+
HostKeyAlgorithms: config.HostKeyAlgorithms,
174+
Config: connConfig,
163175
}, nil
164176
}
165177

0 commit comments

Comments
 (0)