feat: add Go SSH config management functions and type
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.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
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,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user