diff --git a/DOCUMENTACION.md b/DOCUMENTACION.md index 8b58937..8546441 100644 --- a/DOCUMENTACION.md +++ b/DOCUMENTACION.md @@ -12,7 +12,7 @@ Navegador v Contenedor monitor-rpi | - | SSH con usuario/password + | SSH con usuario/password o clave privada v Raspberry Pi activas ``` @@ -118,7 +118,11 @@ Usuario SSH. ### `password` -Password SSH. Se guarda en `config.json`, por lo que el archivo debe permanecer protegido. +Password SSH. Se guarda en `config.json`, por lo que el archivo debe permanecer protegido. Si `privateKeyPath` esta configurado, la clave privada tiene prioridad y no se usa `password`. + +### `privateKeyPath` + +Ruta de la clave privada SSH dentro del contenedor o del host donde corre el monitor. Debe apuntar a una clave privada legible por el proceso del monitor. Para uso en Docker, monta la clave o una carpeta `.ssh` dentro del contenedor. Las claves con passphrase requieren agente SSH disponible; para monitorizacion unattended suele usarse una clave sin passphrase protegida por permisos de archivo. ### `model` @@ -197,7 +201,7 @@ Invoke-RestMethod http://192.168.0.53:8787/api/status -Headers @{Authorization=" Devuelve la configuracion actual. -Nota: actualmente devuelve tambien passwords porque `config.html` permite editarlas. +Nota: actualmente devuelve tambien credenciales porque `config.html` permite editarlas. Protege el acceso HTTP y el archivo `config.json`. ### `POST /api/config` @@ -254,4 +258,3 @@ Reconstruir: cd /home/yamaray/docker/monitorRPi docker compose up -d --build ``` - diff --git a/config.example.json b/config.example.json index d356e7d..9061fd3 100644 --- a/config.example.json +++ b/config.example.json @@ -37,6 +37,7 @@ "host": "192.168.0.46", "username": "pi", "password": "", + "privateKeyPath": "", "role": "Home Assistant Local", "port": 22, "id": "rpi5-ha-main", @@ -49,6 +50,7 @@ "host": "192.168.0.57", "username": "pi", "password": "", + "privateKeyPath": "", "role": "Home Assistant CabaƱa", "port": 22, "id": "rpi4-ha-second", @@ -61,6 +63,7 @@ "host": "192.168.0.53", "username": "yamaray", "password": "", + "privateKeyPath": "", "role": "Docker", "port": 22, "id": "rpi5-jose-docker", @@ -73,6 +76,7 @@ "host": "192.168.0.130", "username": "pi", "password": "", + "privateKeyPath": "", "role": "Docker - Daniel", "port": 22, "id": "rpi5-dani-docker", @@ -85,6 +89,7 @@ "host": "192.168.0.254", "username": "yamaray", "password": "", + "privateKeyPath": "", "role": "nginx - wireguard ", "port": 22, "id": "rpi3-nginx", @@ -97,6 +102,7 @@ "host": "192.168.0.37", "username": "pi", "password": "", + "privateKeyPath": "", "role": "MQTT - varios", "port": 22, "id": "rpi3-pi3home", @@ -109,6 +115,7 @@ "host": "192.168.0.60", "username": "yamaray", "password": "", + "privateKeyPath": "", "role": "Meshcore-Interface", "port": 22, "id": "rpi3-meshcore", @@ -121,6 +128,7 @@ "host": "192.168.1.47", "username": "pi", "password": "", + "privateKeyPath": "", "role": "Reserva", "port": 22, "id": "rpi3-node-3", diff --git a/config.html b/config.html index 39d1aa2..76529a8 100644 --- a/config.html +++ b/config.html @@ -192,6 +192,20 @@ .field-id { grid-column: span 2; } .field-role { grid-column: span 2; } .field-location { grid-column: span 2; } + .field-auth { grid-column: span 1; } + .device[data-auth-method="password"] .key-credential { display: none; } + .device[data-auth-method="key"] .password-credential { display: none; } + + .credential-note { + grid-column: span 2; + color: var(--muted); + font-size: 12px; + line-height: 1.35; + align-self: center; + } + + .device[data-auth-method="key"] .credential-note strong { color: var(--info); } + .device[data-auth-method="password"] .credential-note strong { color: var(--ok); } label { display: grid; @@ -547,8 +561,9 @@ const dashboardLink = document.querySelector("#dashboardLink"); function deviceTemplate(device, index) { + const authMethod = device.privateKeyPath ? "key" : "password"; return ` -