Skip to content

Commit

Permalink
Change remote ssh monitor to default-reject unknown keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesoff committed Nov 5, 2024
1 parent ef4e516 commit f1bca57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/monitors/remote_ssh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ It connects with ``ssh`` to run a remote command, then parses the reply and moni

You should also consider the security risk of having an SSH private key on the monotoring machine. And while we are at the topic of cybersecurity, you should ensure that the SSH command is not injected (this is not liklely if you do not dynamically generate `monitors.ini`)


.. tip::
This Monitor rejects connections to hosts with unknown keys; you should arrange for the host key to be known to the user Simplemonitor is running as in advance (e.g. by sshing to the target hosts once or placing the key in ``known_hosts`` directly).

The sequence of this Monitor is to send to ``ssh_username@target_host:target_port`` the ``command`` via SSH, retrieve the output and parse it with ``regex`` to extract a value.

This value is then compared with ``target_value`` with ``operator``. A failed comparison raises an alert.
Expand Down
2 changes: 1 addition & 1 deletion simplemonitor/Monitors/remote_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def __init__(self, name: str, config_options: dict) -> None:
def run_test(self) -> bool:
# run remote command
with paramiko.SSHClient() as client:
client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
client.set_missing_host_key_policy(paramiko.RejectPolicy)
try:
client.connect(
self.target_hostname,
Expand Down

0 comments on commit f1bca57

Please sign in to comment.