@@ -32,31 +32,35 @@ type (
32
32
// Note: easyssh looking for private key in user's home directory (ex. /home/john + Key).
33
33
// Then ensure your Key begins from '/' (ex. /.ssh/id_rsa)
34
34
MakeConfig struct {
35
- User string
36
- Server string
37
- Key string
38
- KeyPath string
39
- Port string
40
- Passphrase string
41
- Password string
42
- Timeout time.Duration
43
- Proxy DefaultConfig
44
- Ciphers []string
45
- Fingerprint string
35
+ User string
36
+ Server string
37
+ Key string
38
+ KeyPath string
39
+ Port string
40
+ Passphrase string
41
+ Password string
42
+ Timeout time.Duration
43
+ Proxy DefaultConfig
44
+ Ciphers []string
45
+ KeyExchanges []string
46
+ Fingerprint string
47
+ UseInsecureCipher bool
46
48
}
47
49
48
50
// DefaultConfig for ssh proxy config
49
51
DefaultConfig struct {
50
- User string
51
- Server string
52
- Key string
53
- KeyPath string
54
- Port string
55
- Passphrase string
56
- Password string
57
- Timeout time.Duration
58
- Ciphers []string
59
- Fingerprint string
52
+ User string
53
+ Server string
54
+ Key string
55
+ KeyPath string
56
+ Port string
57
+ Passphrase string
58
+ Password string
59
+ Timeout time.Duration
60
+ Ciphers []string
61
+ KeyExchanges []string
62
+ Fingerprint string
63
+ UseInsecureCipher bool
60
64
}
61
65
)
62
66
@@ -125,8 +129,18 @@ func getSSHConfig(config DefaultConfig) (*ssh.ClientConfig, io.Closer) {
125
129
}
126
130
127
131
c := ssh.Config {}
132
+ if config .UseInsecureCipher {
133
+ c .SetDefaults ()
134
+ c .Ciphers = append (c .Ciphers , "aes128-cbc" )
135
+ c .KeyExchanges = append (c .KeyExchanges , "diffie-hellman-group-exchange-sha1" , "diffie-hellman-group-exchange-sha256" )
136
+ }
137
+
128
138
if len (config .Ciphers ) > 0 {
129
- c .Ciphers = config .Ciphers
139
+ c .Ciphers = append (c .Ciphers , config .Ciphers ... )
140
+ }
141
+
142
+ if len (config .KeyExchanges ) > 0 {
143
+ c .KeyExchanges = append (c .KeyExchanges , config .KeyExchanges ... )
130
144
}
131
145
132
146
hostKeyCallback := ssh .InsecureIgnoreHostKey ()
@@ -154,14 +168,15 @@ func (ssh_conf *MakeConfig) Connect() (*ssh.Session, *ssh.Client, error) {
154
168
var err error
155
169
156
170
targetConfig , closer := getSSHConfig (DefaultConfig {
157
- User : ssh_conf .User ,
158
- Key : ssh_conf .Key ,
159
- KeyPath : ssh_conf .KeyPath ,
160
- Passphrase : ssh_conf .Passphrase ,
161
- Password : ssh_conf .Password ,
162
- Timeout : ssh_conf .Timeout ,
163
- Ciphers : ssh_conf .Ciphers ,
164
- Fingerprint : ssh_conf .Fingerprint ,
171
+ User : ssh_conf .User ,
172
+ Key : ssh_conf .Key ,
173
+ KeyPath : ssh_conf .KeyPath ,
174
+ Passphrase : ssh_conf .Passphrase ,
175
+ Password : ssh_conf .Password ,
176
+ Timeout : ssh_conf .Timeout ,
177
+ Ciphers : ssh_conf .Ciphers ,
178
+ KeyExchanges : ssh_conf .KeyExchanges ,
179
+ Fingerprint : ssh_conf .Fingerprint ,
165
180
})
166
181
if closer != nil {
167
182
defer closer .Close ()
@@ -170,14 +185,15 @@ func (ssh_conf *MakeConfig) Connect() (*ssh.Session, *ssh.Client, error) {
170
185
// Enable proxy command
171
186
if ssh_conf .Proxy .Server != "" {
172
187
proxyConfig , closer := getSSHConfig (DefaultConfig {
173
- User : ssh_conf .Proxy .User ,
174
- Key : ssh_conf .Proxy .Key ,
175
- KeyPath : ssh_conf .Proxy .KeyPath ,
176
- Passphrase : ssh_conf .Proxy .Passphrase ,
177
- Password : ssh_conf .Proxy .Password ,
178
- Timeout : ssh_conf .Proxy .Timeout ,
179
- Ciphers : ssh_conf .Proxy .Ciphers ,
180
- Fingerprint : ssh_conf .Proxy .Fingerprint ,
188
+ User : ssh_conf .Proxy .User ,
189
+ Key : ssh_conf .Proxy .Key ,
190
+ KeyPath : ssh_conf .Proxy .KeyPath ,
191
+ Passphrase : ssh_conf .Proxy .Passphrase ,
192
+ Password : ssh_conf .Proxy .Password ,
193
+ Timeout : ssh_conf .Proxy .Timeout ,
194
+ Ciphers : ssh_conf .Proxy .Ciphers ,
195
+ KeyExchanges : ssh_conf .Proxy .KeyExchanges ,
196
+ Fingerprint : ssh_conf .Proxy .Fingerprint ,
181
197
})
182
198
if closer != nil {
183
199
defer closer .Close ()
0 commit comments