[Bug] debsecan silently fails with incorrect ssh error when cluster user is not root@pam
Describe the bug
When running an CVE scan as a non-root user the scan (and install) both fail with "SSH connection failed" despite the credentials working (for API access, manually sshing from pegaprox instance as pegaprox user and via shell access)
Steps to Reproduce
- Add a cluster with a non-root account (e.g. pegaprox@pam) & password
- Attempt to run the CVE scanner
- Attempt to install debsecan
Expected behavior
The CVE scanner should run and return the results. If, which is not the case here, debsecan is not installed it should attempt to install (and most likely will fail due to OS permissions, but not an SSH error)
Environment
- PegaProx Version: 1.1.1
- Installation Method: Installation script
- OS: Debian 13 (Trixie)
- Browser: Firefox ESR (Debian Trixie)
- Behind Reverse Proxy? NGinx as configured in example
- UI? Both
Logs
No output from any logs found regarding to the debsecan attempt. Node does have some SSH logs:
Sep 15 13:01:50 HOST sshd-session[126673]: Connection closed by authenticating user pegaprox 192.168.10.78 port 41494 [preauth]
Sep 15 13:01:50 HOST sshd-session[126697]: Accepted password for pegaprox from X.X.X.X port 41510 ssh2
Sep 15 13:01:50 HOST sshd-session[126697]: pam_unix(sshd:session): session opened for user pegaprox(uid=1001) by pegaprox(uid=0)
Sep 15 13:01:50 HOST sshd-session[126697]: pam_unix(sshd:session): session closed for user pegaprox
Screenshots
Checklist
- [x] I have searched existing issues to make sure this is not a duplicate
- [x] I am using the latest version of PegaProx
Your sshd log is the giveaway: Accepted password and a session that opens and closes cleanly, so SSH itself worked fine.
What happens after that: for a non-root cluster user we wrap every node command as echo <base64> | base64 -d | sudo -n bash (base64 so heredocs and redirects survive). The -n means sudo never prompts — so without NOPASSWD sudo for that user it exits straight away, and the CVE scan collapses any non-zero exit into its single error string, which happens to be an SSH one. The real stderr only goes out at DEBUG level, and the hint classifier we added in #717 has no sudo branch, which is why you found nothing in the logs at all.
So pegaprox ALL=(ALL) NOPASSWD: ALL on the nodes (or narrower, if you'd rather) should get the scan running today. The message is ours to fix though — a sudo refusal should say "sudo" and not blame the connection. Taking that one. Related: #792 wants scoped sudo instead of the blanket sudo bash, which is the same corner.
Nice report, by the way — the sshd lines are exactly what made it a five-minute diagnosis. If PegaProx ends up useful to you, https://opencollective.com/pegaprox is where you can throw something in.
Marcus
Thanks for the response, you are correct in that creating a sudoers file does resolve the issue. And thanks for tagging the related issue (I spotted a previously closed version of it but didn't pick up the repost...).
Incidentally I was also digging around taking a look at how the debsecan was being run as well since I get a different emailed cron report to what pegaprox was producing (opened and detailed in #827).
Fixed on Testing as 6b468ca.
The scan now reports what actually refused instead of blaming the connection, so a sudo problem says "sudo" and names the user. The reason comes from the failing attempt itself and is cleared per call — a timeout records no stderr, and repeating the previous run's cause would just be a wrong answer stated confidently.
Note this doesn't change anything on your side: you still need passwordless sudo for that user, or the scan has nothing to read. It only stops us pointing at the wrong thing while you do it.
Comes with the next release.
Marcus
Out with 1.2.0. The scan names what actually refused instead of blaming the connection, so a sudo problem says sudo and names the user.
Leaving #827 open — the --source idea from that thread is still on the list and I'd rather not lose it in a close.
Marcus
ps. https://opencollective.com/pegaprox if you feel like chipping in