Added the option to supply a ssh password

pull/3/head
Thorsten Sick 3 years ago
parent a4944f9b30
commit 6da13fada3

@ -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 """

@ -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

@ -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",

Loading…
Cancel
Save