[Python-modules-commits] [python-spur] 10/13: SshShell: add load_system_host_keys argument

Ruben Undheim rubund-guest at moszumanska.debian.org
Sun Jan 3 10:38:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

rubund-guest pushed a commit to branch master
in repository python-spur.

commit 643a2d2b1baf51d9bb31b38397533d9f4bd977ae
Author: Michael Williamson <mike at zwobble.org>
Date:   Mon Dec 28 11:10:06 2015 +0000

    SshShell: add load_system_host_keys argument
---
 CHANGES     | 2 ++
 README.rst  | 5 +++++
 spur/ssh.py | 7 +++++--
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/CHANGES b/CHANGES
index b838bd5..8e3ee60 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,8 @@
 
 * Add encoding argument to spawn and run.
 
+* SshShell: add load_system_host_keys argument.
+
 * LocalShell: don't raise NoSuchCommandError when cwd does not exist.
 
 ## 0.3.14
diff --git a/README.rst b/README.rst
index 2b5eb96..c29b027 100644
--- a/README.rst
+++ b/README.rst
@@ -103,6 +103,11 @@ Optional arguments:
 * ``look_for_private_keys`` -- by default, Spur will search for discoverable
   private key files in ``~/.ssh/``.
   Set to ``False`` to disable this behaviour.
+  
+* ``load_system_host_keys`` -- by default, Spur will attempt to read host keys
+  from the user's known hosts file, as used by OpenSSH, and no exception will
+  be raised if the file can’t be read.
+  Set to ``False`` to disable this behaviour.
 
 Shell interface
 ---------------
diff --git a/spur/ssh.py b/spur/ssh.py
index 38319e5..7836ccd 100644
--- a/spur/ssh.py
+++ b/spur/ssh.py
@@ -124,7 +124,8 @@ class SshShell(object):
             connect_timeout=None,
             missing_host_key=None,
             shell_type=None,
-            look_for_private_keys=True):
+            look_for_private_keys=True,
+            load_system_host_keys=True):
         
         if shell_type is None:
             shell_type = ShellTypes.sh
@@ -137,6 +138,7 @@ class SshShell(object):
         self._client = None
         self._connect_timeout = connect_timeout if not None else _ONE_MINUTE
         self._look_for_private_keys = look_for_private_keys
+        self._load_system_host_keys = load_system_host_keys
         self._closed = False
         
         if missing_host_key is None:
@@ -251,7 +253,8 @@ class SshShell(object):
             if self._closed:
                 raise RuntimeError("Shell is closed")
             client = paramiko.SSHClient()
-            client.load_system_host_keys()
+            if self._load_system_host_keys:
+                client.load_system_host_keys()
             client.set_missing_host_key_policy(self._missing_host_key)
             client.connect(
                 hostname=self._hostname,

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-spur.git



More information about the Python-modules-commits mailing list