Files
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

1.6 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, 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 params output tested tests test_file_path file_path
ssh_tunnel_open function go infra 1.0.0 impure func SSHTunnelOpen(conn SSHConn, localPort int, remoteHost string, remotePort int) (int, error) Abre un tunel SSH (local port forwarding) en background. Retorna el PID del proceso para cerrarlo despues.
ssh
tunnel
port-forwarding
remote
pendiente-usar
ssh_conn_go_infra
false error_go_core
fmt
os/exec
strings
time
name desc
conn estructura SSHConn con Host, User, Port, IdentityFile
name desc
localPort puerto local donde escuchar conexiones
name desc
remoteHost host remoto accesible desde el servidor SSH
name desc
remotePort puerto en el host remoto
PID del proceso ssh del tunel para cerrarlo despues true
abre tunel y lo cierra
functions/infra/ssh_tunnel_test.go functions/infra/ssh_tunnel_open.go

Ejemplo

conn := SSHConn{Host: "bastion.example.com", User: "deploy"}
// Tunel: localhost:5432 -> db-server:5432 via bastion
pid, err := SSHTunnelOpen(conn, 5432, "db-server", 5432)
if err != nil {
    log.Fatal(err)
}
fmt.Println("tunnel PID:", pid)
// Usar localhost:5432 para conectar a la BD remota
// Cerrar con SSHTunnelClose(pid)

Notas

Usa ssh -N -f -L para crear el tunel en background. ExitOnForwardFailure=yes falla inmediatamente si el puerto local esta ocupado. remoteHost vacio se interpreta como "localhost" (el servidor SSH mismo). El PID se obtiene buscando el proceso ssh en la tabla de procesos.