Files
fn_registry/functions/infra/ssh_download.go
T
egutierrez 560cbf280e feat: funciones SSH para infra — conn, check, exec, download, upload, tunnel
Conjunto completo de funciones SSH para operaciones remotas: conexión,
verificación de host, ejecución de comandos, transferencia de archivos
(upload/download) y gestión de túneles. Incluye tipo SSHConn y tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 22:03:41 +02:00

21 lines
521 B
Go

package infra
import (
"fmt"
"os/exec"
"strings"
)
// SSHDownload descarga un archivo del host remoto al filesystem local via scp.
func SSHDownload(conn SSHConn, remotePath, localPath string) error {
args := conn.scpArgs()
src := fmt.Sprintf("%s:%s", conn.destination(), remotePath)
args = append(args, src, localPath)
out, err := exec.Command("scp", args...).CombinedOutput()
if err != nil {
return fmt.Errorf("scp download from %s: %s", conn.destination(), strings.TrimSpace(string(out)))
}
return nil
}