Lock ssh handshake
This commit is contained in:
parent
d4f826d44b
commit
b558269ac3
@ -15,6 +15,7 @@ import (
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
@ -364,7 +365,12 @@ func (q System) WaitForSSH(timeout time.Duration) error {
|
||||
return errors.New("no ssh (timeout)")
|
||||
}
|
||||
|
||||
var sshMu sync.Mutex
|
||||
|
||||
func (q System) ssh(user string) (client *ssh.Client, err error) {
|
||||
sshMu.Lock()
|
||||
defer sshMu.Unlock()
|
||||
|
||||
cfg := &ssh.ClientConfig{
|
||||
User: user,
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
@ -464,7 +470,9 @@ func (q System) scp(user, localPath, remotePath string, recursive bool) (err err
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(),
|
||||
}
|
||||
|
||||
sshMu.Lock()
|
||||
client, err := scp.NewClient(q.sshAddrPort, cfg, &scp.ClientOption{})
|
||||
sshMu.Unlock()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user