diff --git a/app/config.py b/app/config.py index a16631d..7106274 100644 --- a/app/config.py +++ b/app/config.py @@ -102,6 +102,11 @@ class MachineConfig(): return self.raw_config.get("ssh_user", "vagrant") + def ssh_password(self): + """ Returns configured ssh password or None as default """ + + return self.raw_config.get("ssh_password", None) + def halt_needs_force(self): """ Returns if halting the machine needs force False as default """ diff --git a/demo.yaml b/demo.yaml index de51c16..494ca02 100644 --- a/demo.yaml +++ b/demo.yaml @@ -61,7 +61,7 @@ targets: # Targets need a unique PAW name for caldera paw: target1 ### - # Targets need to be in a group for caldera + # Targets need to be in a group for caldera. The group is more relevant than the paw. Better put every target in a unique group group: red machinepath: target1 @@ -89,6 +89,8 @@ targets: vm_name: target2 os: windows paw: target2w + ### + # Targets need to be in a group for caldera. The group is more relevant than the paw. Better put every target in a unique group group: red machinepath: target2w @@ -103,6 +105,10 @@ targets: # If SSH without vagrant support is used (Windows !) we need a user name (uppercase) ssh_user: PURPLEDOME + ### + # If SSH without vagrant support is used (Windows !) we maybe need a password + ssh_password: PURPLEDOME + ### # For non-vagrant ssh connections a ssh keyfile stored in the machinepath is required. ssh_keyfile: id_rsa.3 @@ -137,7 +143,7 @@ targets: # Targets need a unique PAW name for caldera paw: target3 ### - # Targets need to be in a group for caldera + # Targets need to be in a group for caldera. The group is more relevant than the paw. Better put every target in a unique group group: red machinepath: target3 diff --git a/tests/test_config.py b/tests/test_config.py index 76f7c47..f1ae05f 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -321,6 +321,32 @@ class TestMachineConfig(unittest.TestCase): "use_existing_machine": False}) self.assertEqual(mc.ssh_user(), "vagrant") + def test_ssh_password(self): + """ Testing ssh password config """ + mc = MachineConfig({"root": "systems/attacker1", + "os": "linux", + "ssh_user": "Bob", + "ssh_password": "Ross", + "vm_controller": { + "type": "vagrant", + "vagrantfilepath": "systems", + }, + "vm_name": "target1", + "use_existing_machine": False}) + self.assertEqual(mc.ssh_password(), "Ross") + + def test_ssh_password_default(self): + """ Testing ssh password default config """ + mc = MachineConfig({"root": "systems/attacker1", + "os": "linux", + "vm_controller": { + "type": "vagrant", + "vagrantfilepath": "systems", + }, + "vm_name": "target1", + "use_existing_machine": False}) + self.assertIsNone(mc.ssh_password()) + def test_halt_needs_force_default(self): """ Testing 'halt needs force' default config """ mc = MachineConfig({"root": "systems/attacker1",