6d0d63cb23
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>
1.1 KiB
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. |
|
|
false | error_go_core |
|
true |
|
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.