--- name: ssh_exec kind: function lang: go domain: infra version: "1.0.0" purity: impure signature: "func SSHExec(conn SSHConn, command string) (string, string, int, error)" description: "Ejecuta un comando en el host remoto via SSH. Retorna stdout, stderr y exit code separados." tags: [ssh, exec, remote, command] uses_functions: [] uses_types: [ssh_conn_go_infra] returns: [] returns_optional: false error_type: "error_go_core" imports: [os/exec] params: - name: conn desc: "estructura SSHConn con Host, User, Port, IdentityFile" - name: command desc: "comando a ejecutar en el host remoto" output: "tupla (stdout, stderr, exit_code, error) del comando ejecutado" tested: true tests: ["echo simple", "captura stderr", "exit code no cero", "comando multilinea"] test_file_path: "functions/infra/ssh_exec_test.go" file_path: "functions/infra/ssh_exec.go" --- ## Ejemplo ```go 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.