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.
This commit is contained in:
Ilija Lazoroski 2022-04-06 17:01:30 +02:00
parent f2a8dcc908
commit 2d800e4502
1 changed files with 6 additions and 14 deletions

View File

@ -185,21 +185,13 @@ class ConfigService:
) )
@staticmethod @staticmethod
def ssh_add_keys(public_key, private_key, user, ip): def ssh_add_keys(public_key, private_key):
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( ConfigService.add_item_to_config_set_if_dont_exist(
SSH_KEYS_PATH, SSH_KEYS_PATH,
{"public_key": public_key, "private_key": private_key, "user": user, "ip": ip}, {"public_key": public_key, "private_key": private_key},
# SSH keys already encrypted in process_ssh_info() should_encrypt=True,
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 _filter_none_values(data): def _filter_none_values(data):
if isinstance(data, dict): if isinstance(data, dict):
return { return {