From 2d800e4502ff3a1d5fabadc1499feae678489c92 Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Wed, 6 Apr 2022 17:01:30 +0200 Subject: [PATCH] Island: Remove identification of ssh keys by username and ip `ssh_key_exists` is identifing ssh keys based on username and ip which is wrong. --- monkey/monkey_island/cc/services/config.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/monkey/monkey_island/cc/services/config.py b/monkey/monkey_island/cc/services/config.py index a45889e70..f0977ef66 100644 --- a/monkey/monkey_island/cc/services/config.py +++ b/monkey/monkey_island/cc/services/config.py @@ -185,20 +185,12 @@ class ConfigService: ) @staticmethod - def ssh_add_keys(public_key, private_key, user, ip): - if not ConfigService.ssh_key_exists( - ConfigService.get_config_value(SSH_KEYS_PATH, False, False), user, ip - ): - ConfigService.add_item_to_config_set_if_dont_exist( - SSH_KEYS_PATH, - {"public_key": public_key, "private_key": private_key, "user": user, "ip": ip}, - # SSH keys already encrypted in process_ssh_info() - should_encrypt=False, - ) - - @staticmethod - def ssh_key_exists(keys, user, ip): - return [key for key in keys if key["user"] == user and key["ip"] == ip] + def ssh_add_keys(public_key, private_key): + ConfigService.add_item_to_config_set_if_dont_exist( + SSH_KEYS_PATH, + {"public_key": public_key, "private_key": private_key}, + should_encrypt=True, + ) def _filter_none_values(data): if isinstance(data, dict):