diff --git a/monkey/infection_monkey/credential_collectors/credential_components/ssh_keypair.py b/monkey/infection_monkey/credential_collectors/credential_components/ssh_keypair.py index c23833681..c5f377c44 100644 --- a/monkey/infection_monkey/credential_collectors/credential_components/ssh_keypair.py +++ b/monkey/infection_monkey/credential_collectors/credential_components/ssh_keypair.py @@ -6,4 +6,5 @@ from infection_monkey.i_puppet import CredentialType, ICredentialComponent @dataclass(frozen=True) class SSHKeypair(ICredentialComponent): credential_type: CredentialType = field(default=CredentialType.SSH_KEYPAIR, init=False) - content: dict + private_key: str + public_key: str diff --git a/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py b/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py index bdcc56098..ce64221fb 100644 --- a/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py +++ b/monkey/infection_monkey/credential_collectors/ssh_collector/ssh_credential_collector.py @@ -41,7 +41,11 @@ class SSHCredentialCollector(ICredentialCollector): ssh_keypair[key] = info[key] if len(ssh_keypair): - secrets.append(SSHKeypair(ssh_keypair)) + secrets.append( + SSHKeypair( + ssh_keypair.get("private_key", ""), ssh_keypair.get("public_key", "") + ) + ) if identities != [] or secrets != []: ssh_credentials.append(Credentials(identities, secrets)) diff --git a/monkey/tests/unit_tests/infection_monkey/credential_collectors/linux_credentials_collector/test_ssh_credentials_collector.py b/monkey/tests/unit_tests/infection_monkey/credential_collectors/linux_credentials_collector/test_ssh_credentials_collector.py index 2762892bf..3727f8698 100644 --- a/monkey/tests/unit_tests/infection_monkey/credential_collectors/linux_credentials_collector/test_ssh_credentials_collector.py +++ b/monkey/tests/unit_tests/infection_monkey/credential_collectors/linux_credentials_collector/test_ssh_credentials_collector.py @@ -52,10 +52,8 @@ def test_ssh_info_result_parsing(monkeypatch, patch_telemetry_messenger): username2 = Username("mcus") username3 = Username("guest") - ssh_keypair1 = SSHKeypair( - {"public_key": "SomePublicKeyUbuntu", "private_key": "ExtremelyGoodPrivateKey"} - ) - ssh_keypair2 = SSHKeypair({"public_key": "AnotherPublicKey"}) + ssh_keypair1 = SSHKeypair("ExtremelyGoodPrivateKey", "SomePublicKeyUbuntu") + ssh_keypair2 = SSHKeypair("", "AnotherPublicKey") expected = [ Credentials(identities=[username], secrets=[ssh_keypair1]),