Files
fn_registry/functions/infra/ssh_exec.md
T
egutierrez 6d0d63cb23 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

1.1 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path
ssh_exec function go infra 1.0.0 impure func SSHExec(conn SSHConn, command string) (string, string, int, error) Ejecuta un comando en el host remoto via SSH. Retorna stdout, stderr y exit code separados.
ssh
exec
remote
command
ssh_conn_go_infra
false error_go_core
os/exec
true
echo simple
captura stderr
exit code no cero
comando multilinea
functions/infra/ssh_exec_test.go functions/infra/ssh_exec.go

Ejemplo

conn := SSHConn{Host: "192.168.1.100", User: "deploy"}
stdout, stderr, code, err := SSHExec(conn, "df -h /")
if err != nil {
    log.Fatal(err)
}
fmt.Printf("exit=%d\nstdout:\n%s\nstderr:\n%s\n", code, stdout, stderr)

Notas

Retorna stdout y stderr como strings separados mas el exit code. Si el comando remoto falla (exit code != 0), NO retorna error — el exit code indica el fallo. Solo retorna error si ssh no pudo conectar o ejecutar. Usa BatchMode=yes para evitar prompts interactivos.