1
0

Use the legacy SCP protocol for directory transfers instead of SFTP

This commit is contained in:
dump_stack() 2023-03-19 17:56:09 +00:00
parent 04106e7537
commit 60bc7238a8
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -391,6 +391,27 @@ func (q System) scp(user, localPath, remotePath string, recursive bool) (err err
} }
if recursive { if recursive {
var output []byte
output, err = exec.Command("ssh", "-V").CombinedOutput()
if err != nil {
return
}
sshVersion := string(output)
log.Debug().Str("ssh version", sshVersion).Msg("")
if strings.Contains(sshVersion, "OpenSSH_9") {
// This release switches scp from using the
// legacy scp/rcp protocol to using the SFTP
// protocol by default.
//
// To keep compatibility with old distros,
// using -O flag to use the legacy scp/rcp.
//
// Note: old ssh doesn't support -O flag
args = append(args, "-O")
}
args = append(args, "-r") args = append(args, "-r")
} }