ab7317b0c0
7 funciones Go del dominio infra para gestion programatica de ~/.ssh/config: ssh_config_parse (parser de bloques Host/Match), ssh_config_read (lectura del archivo), ssh_config_find (busqueda por host), ssh_config_add_entry y ssh_config_remove_entry (CRUD), ssh_config_render (serializacion a texto), ssh_config_write (escritura atomica). Incluye tipo SshConfigEntry (product type) y tests unitarios del parser.
22 lines
792 B
Go
22 lines
792 B
Go
package infra
|
|
|
|
// SSHConfigEntry representa un bloque Host en ~/.ssh/config.
|
|
type SSHConfigEntry struct {
|
|
Alias string // Nombre del host (lo que va despues de "Host")
|
|
HostName string // IP o hostname real del servidor
|
|
User string // Usuario remoto
|
|
Port int // Puerto SSH (0 = no especificado, usa default 22)
|
|
IdentityFile string // Ruta a clave privada
|
|
Options map[string]string // Opciones SSH adicionales (ForwardAgent, ProxyJump, etc.)
|
|
}
|
|
|
|
// ToSSHConn convierte un SSHConfigEntry a SSHConn para usar con las funciones SSH del registry.
|
|
func (e SSHConfigEntry) ToSSHConn() SSHConn {
|
|
return SSHConn{
|
|
Host: e.HostName,
|
|
Port: e.Port,
|
|
User: e.User,
|
|
KeyPath: e.IdentityFile,
|
|
}
|
|
}
|