project-pegaprox icon indicating copy to clipboard operation
project-pegaprox copied to clipboard

[Bug] Sensor and in-band BMC probes SSH as `root` and ignore the cluster's API user (failed root logins every hour)

Open buckets-dev opened this issue 4 weeks ago • 2 comments

Hey there! 👋 Thanks for taking the time to report this bug — we appreciate it!

Please keep in mind: PegaProx is developed and maintained entirely by volunteers in our free time. We do our best, but we can't work magic 🪄 — please be patient, we'll get to your issue as soon as we can.

Want to help keep PegaProx alive?

  • ⭐ Star the project — it's free and helps a lot!
  • 💖 Become a Sponsor — helps us dedicate more time to development
  • 🤝 Contributing code or docs is always welcome too!

Describe the bug

Version: PegaProx 1.4.1 (build 2026-10-24), Proxmox VE 9.2 cluster

Summary With an SSH key set on a PVE cluster and the API user someuser@pve!token, PegaProx logs in to the nodes as someuser for everything that goes through _ssh_connect (compliance checks, connection check). The hourly temperature and in-band BMC probes still connect as root. The PVE cluster dialog has no ssh_user field, so a least-privilege setup (a non-root account with sudo, as the docs recommend) gets failed root SSH logins from PegaProx on every node, about every hour.

Cause (1.4.1 source)

  • core/manager.py _ssh_connect: username = self.config.ssh_user if self.config.ssh_user else self.config.user.split('@')[0]
  • core/conncheck.py _ssh_user(): same derivation (cfg.ssh_user or (cfg.user or 'root').split('@')[0]).
  • But core/manager.py get_node_sensors(): user = getattr(self.config, 'ssh_user', None) or 'root'
  • and core/bmc.py read_node_bmc_inband(): user = getattr(mgr.config, 'ssh_user', None) or 'root' Both are called from background/metrics.py (_node_hottest_temp, _node_hw_summary); a failure parks the node for ~1 h, so the root attempt repeats hourly.

Steps to Reproduce

  1. Observed
  • sshd/auditd on each node: USER_LOGIN acct=root ... exe=/usr/lib/openssh/sshd-session res=failed from the PegaProx host, about 20 per node per day, starting the moment the cluster SSH key was set.
  • PegaProx log at the same minute: [NodeIP] <node> -> <ip> (cluster/status, reachable on :22), with no error logged.

Expected behavior

The probes use the same login as _ssh_connect (explicit ssh_user, else the API user's name). If root can't log in, they should log once rather than retry every hour.

Suggested fix Use one helper everywhere (for example reuse conncheck._ssh_user(mgr)) in get_node_sensors() and read_node_bmc_inband(), and wrap the in-band ipmitool call in sudo -n for non-root users, like the other node commands do (sudo -n bash).

Also worth considering

  • Expose ssh_user in the PVE "Re-configure Cluster" dialog. It is accepted by PUT /api/clusters/<id> (ALLOWED_CONFIG_FIELDS), but there is no UI field for it. Re-saving the dialog rebuilds the config from the form body, which silently clears an ssh_user that was set through the API.
  • The dialog's help text says "its public key must be in /root/.ssh/authorized_keys" even when the login is not root.

Workaround PUT /api/clusters/<id> with {"ssh_user": "<non-root user>"}.

Environment

  • PegaProx Version: PegaProx 1.4.1 (build 2026-10-24), Proxmox VE 9.2 cluster
  • Installation Method: Manual
  • OS: Debian 12
  • Browser: Chrome

Logs


Screenshots

Checklist

  • [*] I have searched existing issues to make sure this is not a duplicate
  • [*] I am using the latest version of PegaProx
  • [*] I've put enough in here that someone can start on it without asking me three questions first
  • [*] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄

buckets-dev avatar Nov 08 '26 05:11 buckets-dev

Thanks, that was spot on, and it went further than the sensor and BMC reads. Roughly half the node SSH paths took the API user's name as the login and the other half root, and several HA paths ignored an explicit ssh_user too.

On Testing now (f6d26cdf..8ec6f790): every path logs in as the cluster's SSH user, root when none is set, which is what the dialog and the docs always said. With someuser@pve!token, keep the ssh_user you set through the API; it now covers the sensor and BMC reads, the HA agents and everything else. The cluster password only goes along when the login is that same @pam account, so it no longer reaches a login it can't belong to.

The Re-configure dialog has an SSH user field now, and a re-save keeps what the dialog doesn't show: your ssh_user, the stored key (an empty key field keeps it), a custom SSH port and a few other settings that were silently reset as well. The help text names that user's authorized_keys instead of root's.

Non-root logins already ran node commands through sudo -n bash, ipmitool included, so nothing changed there. With the right login the hourly root attempts stop; I didn't add a separate backoff for refused logins.

The issue stays open until this is in a release. If PegaProx saves you some time, the project runs on donations: https://opencollective.com/pegaprox

Marcus

mkellermann97 avatar Nov 08 '26 15:11 mkellermann97

With 1.5.0 one SSH user is used for every node login, sensors and the in-band BMC probe included, so no more root attempts where the cluster has its own user. Released today, closing.

MrMasterbay avatar Nov 15 '26 01:11 MrMasterbay