Skip to content

Commit 2ecd08e

Browse files
committed
fix(by-ssh): traceback on "permission denied"
1 parent 719b7c1 commit 2ecd08e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Build, CI/CD:
2727

2828
Monitoring Plugins:
2929

30+
* by-ssh: fix traceback on "permission denied"
3031
* needs-restarting: add missung import of lib.disk
3132
* ping: '10 received' contains '0 received' ([#860](https://github.com/Linuxfabrik/monitoring-plugins/issues/860))
3233

check-plugins/by-ssh/by-ssh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ from lib.globals import (STATE_CRIT, STATE_OK, # pylint: disable=C0413
2626

2727

2828
__author__ = 'Linuxfabrik GmbH, Zurich/Switzerland'
29-
__version__ = '2025021501'
29+
__version__ = '2025051301'
3030

3131
DESCRIPTION = """This plugin uses SSH to execute a command on a remote host,
3232
returning STDOUT and, in case of failure, STDERR and the command's return code.
@@ -309,8 +309,9 @@ def main():
309309
)
310310
timer_start = lib.time.now('float')
311311
stdout, stderr, retc = lib.base.coe(lib.shell.shell_exec(cmd, shell=args.SHELL))
312-
if args.PASSWORD and retc:
313-
# stderr will not be set, we just get "Permission denied""
312+
if args.PASSWORD and not stderr and retc in range(1, 8):
313+
# we got a specific sshpass return code (this also means stderr = ""), and not just
314+
# something like stderr = "Permission denied" with retc 127 or 255
314315
stderr = 'sshpass: {}'.format(lib.shell.RETC_SSHPASS[retc])
315316

316317
perfdata = lib.base.get_perfdata('remote_runtime', lib.time.now('float') - timer_start, 's')

0 commit comments

Comments
 (0)