Skip to content

Commit b65d9d0

Browse files
committed
Fix container SSH detection and improve troubleshooting for issue #617
Related to #617 This fixes a misconfiguration scenario where Docker containers could attempt direct SSH connections (producing [preauth] log spam) instead of using the sensor proxy. Changes: - Fix container detection to check PULSE_DOCKER=true in addition to system.InContainer() heuristics (both temperature.go and config_handlers.go) - Upgrade temperature collection log from Error to Warn with actionable guidance about mounting the proxy socket - Add Info log when dev mode override is active so operators understand the security posture - Add troubleshooting section to docs for SSH [preauth] logs from containers The container detection was inconsistent - monitor.go checked both flags but temperature.go and config_handlers.go only checked InContainer(). Now all locations consistently check PULSE_DOCKER || InContainer().
1 parent 919c944 commit b65d9d0

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

docs/TEMPERATURE_MONITORING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,28 @@ You should see JSON output with temperature data.
359359

360360
## Troubleshooting
361361

362+
### SSH Connection Attempts from Container ([preauth] Logs)
363+
364+
**Symptom:** Proxmox host logs (`/var/log/auth.log`) show repeated SSH connection attempts from your Pulse container:
365+
```
366+
Connection closed by authenticating user root <container-ip> port <port> [preauth]
367+
```
368+
369+
**This indicates a misconfiguration.** Containerized Pulse should communicate via the sensor proxy, not direct SSH.
370+
371+
**Common causes:**
372+
- Dev mode enabled (`PULSE_DEV_ALLOW_CONTAINER_SSH=true` environment variable)
373+
- Sensor proxy not installed or socket not accessible
374+
- Legacy SSH keys from pre-v4.24.0 installations
375+
376+
**Fix:**
377+
- **Docker:** Follow [Quick Start for Docker Deployments](#quick-start-for-docker-deployments) to install the proxy and add the bind mount
378+
- **LXC:** Run the setup script on your Proxmox host (see [Setup (Automatic)](#setup-automatic))
379+
- **Dev mode:** Remove `PULSE_DEV_ALLOW_CONTAINER_SSH=true` from your environment/docker-compose
380+
- **Verify:** Check Pulse logs for `Temperature proxy detected - using secure host-side bridge`
381+
382+
Once the proxy is properly configured, these log entries will stop immediately. See [Container Security Considerations](#container-security-considerations) for why direct container SSH is blocked.
383+
362384
### No Temperature Data Shown
363385

364386
**Check SSH access**:

internal/api/config_handlers.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,15 +5878,17 @@ func (h *ConfigHandlers) getOrGenerateSSHKeys() SSHKeyPair {
58785878
// CRITICAL SECURITY CHECK: Never generate SSH keys in containers (unless dev mode)
58795879
// Container compromise = SSH key compromise = root access to Proxmox
58805880
devModeAllowSSH := os.Getenv("PULSE_DEV_ALLOW_CONTAINER_SSH") == "true"
5881-
if system.InContainer() && !devModeAllowSSH {
5881+
isContainer := os.Getenv("PULSE_DOCKER") == "true" || system.InContainer()
5882+
5883+
if isContainer && !devModeAllowSSH {
58825884
log.Error().Msg("SECURITY BLOCK: SSH key generation disabled in containerized deployments")
58835885
log.Error().Msg("For temperature monitoring in containers, deploy pulse-sensor-proxy on the Proxmox host")
58845886
log.Error().Msg("See: https://github.com/rcourtman/Pulse/blob/main/SECURITY.md#critical-security-notice-for-container-deployments")
58855887
log.Error().Msg("To test SSH keys in dev/lab only: PULSE_DEV_ALLOW_CONTAINER_SSH=true (NEVER in production!)")
58865888
return SSHKeyPair{}
58875889
}
58885890

5889-
if devModeAllowSSH && system.InContainer() {
5891+
if devModeAllowSSH && isContainer {
58905892
log.Warn().Msg("⚠️ DEV MODE: SSH key generation ENABLED in container - FOR TESTING ONLY")
58915893
log.Warn().Msg("⚠️ This grants root SSH access from container - NEVER use in production!")
58925894
}

internal/monitoring/temperature.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,19 @@ func (tc *TemperatureCollector) CollectTemperature(ctx context.Context, nodeHost
114114
// SECURITY: Block SSH fallback when running in containers (unless dev mode)
115115
// Container compromise = SSH key compromise = root access to infrastructure
116116
devModeAllowSSH := os.Getenv("PULSE_DEV_ALLOW_CONTAINER_SSH") == "true"
117-
if system.InContainer() && !devModeAllowSSH {
118-
log.Error().
117+
isContainer := os.Getenv("PULSE_DOCKER") == "true" || system.InContainer()
118+
119+
if isContainer && devModeAllowSSH {
120+
// Log when dev override is active so operators understand the security posture
121+
log.Info().
122+
Str("node", nodeName).
123+
Msg("Temperature collection using direct SSH (dev mode override active - not for production)")
124+
}
125+
126+
if isContainer && !devModeAllowSSH {
127+
log.Warn().
119128
Str("node", nodeName).
120-
Msg("SECURITY BLOCK: SSH temperature collection disabled in containers - deploy pulse-sensor-proxy")
129+
Msg("Temperature collection disabled: containerized Pulse requires pulse-sensor-proxy. Mount /run/pulse-sensor-proxy or set PULSE_DEV_ALLOW_CONTAINER_SSH=true for development only")
121130
return &models.Temperature{Available: false}, nil
122131
}
123132

0 commit comments

Comments
 (0)