@@ -117,15 +117,15 @@ func (c *Connect) CreateClient(host, port, user string, authMethods []ssh.AuthMe
117
117
uri := net .JoinHostPort (host , port )
118
118
119
119
timeout := 20
120
- if c .ConnectTimeout > 0 {
121
- timeout = c .ConnectTimeout
120
+ if c .ConnectTimeout == 0 {
121
+ c .ConnectTimeout = timeout
122
122
}
123
123
124
124
// Create new ssh.ClientConfig{}
125
125
config := & ssh.ClientConfig {
126
126
User : user ,
127
127
Auth : authMethods ,
128
- Timeout : time .Duration (timeout ) * time .Second ,
128
+ Timeout : time .Duration (c . ConnectTimeout ) * time .Second ,
129
129
}
130
130
131
131
if c .HostKeyCallback != nil {
@@ -147,7 +147,7 @@ func (c *Connect) CreateClient(host, port, user string, authMethods []ssh.AuthMe
147
147
c .ProxyDialer = proxy .Direct
148
148
}
149
149
150
- ctx , cancel := context .WithTimeout (context .Background (), time .Duration (timeout )* time .Second )
150
+ ctx , cancel := context .WithTimeout (context .Background (), time .Duration (c . ConnectTimeout )* time .Second )
151
151
defer cancel ()
152
152
153
153
// Dial to host:port
@@ -157,7 +157,7 @@ func (c *Connect) CreateClient(host, port, user string, authMethods []ssh.AuthMe
157
157
}
158
158
159
159
// Set deadline
160
- netConn .SetDeadline (time .Now ().Add (time .Duration (timeout ) * time .Second ))
160
+ netConn .SetDeadline (time .Now ().Add (time .Duration (c . ConnectTimeout ) * time .Second ))
161
161
162
162
// Create new ssh connect
163
163
sshCon , channel , req , cerr := ssh .NewClientConn (netConn , uri , config )
0 commit comments