Added password support to ssh connections

pull/3/head
Thorsten Sick 4 years ago
parent fc0c7839e2
commit db0ca00f6b

@ -72,10 +72,15 @@ class RunningVMPlugin(MachineryPlugin):
self.c = Connection(uhp, connect_timeout=timeout) self.c = Connection(uhp, connect_timeout=timeout)
if self.config.os() == "windows": if self.config.os() == "windows":
args = {}
# args = {"key_filename": self.config.ssh_keyfile() or self.v.keyfile(vm_name=self.config.vmname())} # args = {"key_filename": self.config.ssh_keyfile() or self.v.keyfile(vm_name=self.config.vmname())}
if self.config.ssh_keyfile():
args["key_filename"] = self.config.ssh_keyfile()
if self.config.ssh_password():
args["password"] = self.config.ssh_password()
uhp = self.get_ip() uhp = self.get_ip()
print(f"\n\n !!!!! Connecting to {uhp} !!!!!!!!!! \n\n") print(f"\n\n !!!!! Connecting to {uhp} !!!!!!!!!! \n\n")
self.c = Connection(uhp, connect_timeout=timeout, user=self.config.ssh_user()) self.c = Connection(uhp, connect_timeout=timeout, user=self.config.ssh_user(), connection_kwargs=args)
except (paramiko.ssh_exception.SSHException, socket.timeout): except (paramiko.ssh_exception.SSHException, socket.timeout):
print(f"Failed to connect, will retry {retries} times. Timeout: {timeout}") print(f"Failed to connect, will retry {retries} times. Timeout: {timeout}")
retries -= 1 retries -= 1

@ -85,6 +85,8 @@ class VagrantPlugin(MachineryPlugin):
if self.config.os() == "windows": if self.config.os() == "windows":
args = {"key_filename": os.path.join(self.sysconf["abs_machinepath_external"], self.config.ssh_keyfile())} args = {"key_filename": os.path.join(self.sysconf["abs_machinepath_external"], self.config.ssh_keyfile())}
if self.config.ssh_password():
args["password"] = self.config.ssh_password()
uhp = self.get_ip() uhp = self.get_ip()
print(uhp) print(uhp)
print(args) print(args)

Loading…
Cancel
Save