diff --git a/monkey/infection_monkey/exploit/sshexec.py b/monkey/infection_monkey/exploit/sshexec.py index 9d88c0472..233a718ec 100644 --- a/monkey/infection_monkey/exploit/sshexec.py +++ b/monkey/infection_monkey/exploit/sshexec.py @@ -118,7 +118,14 @@ class SSHExploiter(HostExploiter): self.report_login_attempt(False, user, ssh_key=ssh_string) continue except Exception as err: - logger.error(f"Unknown error while attempting to login with ssh key: {err}") + error_message = ( + f"Unexpected error while attempting to login to {ssh_string} with ssh key: " + f"{err}" + ) + logger.error(error_message) + self._publish_exploitation_event(timestamp, False, error_message=error_message) + self.report_login_attempt(False, user, ssh_key=ssh_string) + raise FailedExploitationError def exploit_with_login_creds(self, port: int) -> paramiko.SSHClient: @@ -167,7 +174,14 @@ class SSHExploiter(HostExploiter): ssh.close() continue except Exception as err: - logger.error(f"Unknown error occurred while trying to login to ssh: {err}") + error_message = ( + f"Unexpected error while attempting to login to {self.host} with password: " + f"{err}" + ) + logger.error(error_message) + self._publish_exploitation_event(timestamp, False, error_message=error_message) + self.report_login_attempt(False, user, current_password) + raise FailedExploitationError def _exploit_host(self) -> ExploiterResultData: