From d26c46ba7fad1de188e8fcf9d187b2b323479efb Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 16 Sep 2017 22:11:03 +0530 Subject: [PATCH] ssh: Support disabling strict host key checking. --- mitogen/ssh.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mitogen/ssh.py b/mitogen/ssh.py index 3fed607f..6bb4a73a 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -16,20 +16,28 @@ class Stream(mitogen.master.Stream): port = None def construct(self, hostname, username=None, ssh_path=None, port=None, - **kwargs): + check_host_keys=True, **kwargs): super(Stream, self).construct(**kwargs) self.hostname = hostname self.username = username self.port = port + self.check_host_keys = check_host_keys if ssh_path: self.ssh_path = ssh_path def get_boot_command(self): bits = [self.ssh_path] + bits += ['-o', 'BatchMode yes'] + if self.username: bits += ['-l', self.username] if self.port is not None: bits += ['-p', str(self.port)] + if not self.check_host_keys: + bits += [ + '-o', 'StrictHostKeyChecking no', + '-o', 'UserKnownHostsFile /dev/null', + ] bits.append(self.hostname) base = super(Stream, self).get_boot_command() return bits + map(commands.mkarg, base)