From 60bc7238a8abbafc13297a222b6d38ab21142392 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sun, 19 Mar 2023 17:56:09 +0000 Subject: [PATCH] Use the legacy SCP protocol for directory transfers instead of SFTP --- qemu/qemu-kernel.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qemu/qemu-kernel.go b/qemu/qemu-kernel.go index 4aec866..249f932 100644 --- a/qemu/qemu-kernel.go +++ b/qemu/qemu-kernel.go @@ -391,6 +391,27 @@ func (q System) scp(user, localPath, remotePath string, recursive bool) (err err } 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") }