]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Add config option 'verify_host_keys'
authorZack Cerza <zack@cerza.org>
Tue, 24 Sep 2013 16:48:11 +0000 (11:48 -0500)
committerZack Cerza <zack@cerza.org>
Tue, 24 Sep 2013 20:04:39 +0000 (15:04 -0500)
Defaults to True, meaning no change in behavior. If False, don't have
paramiko verify ssh host keys.

teuthology/config.py
teuthology/orchestra/connection.py

index e11901a7eafb2e75e6a3b34f28f4f621adc8fc85..195ad69d52f8faf59f0036b512d7c3b391d9d8d6 100644 (file)
@@ -46,6 +46,15 @@ class Config(object):
         base_url = base_url or "https://github.com/ceph/"
         return base_url
 
+    @property
+    def verify_host_keys(self):
+        """
+        Whether or not we should verify ssh host keys.
+
+        Defaults to True
+        """
+        return self.__conf.get('verify_host_keys', True)
+
     # This takes care of any and all of the rest.
     # If the parameter is defined, return it. Otherwise return None.
     def __getattr__(self, name):
index 2473c19b1480ec53d21e99d136905aa296c31f10..b678833b074612479226e217745649abfbebbc9b 100644 (file)
@@ -1,5 +1,6 @@
 import base64
 import paramiko
+from ..config import config
 
 def split_user(user_at_host):
     try:
@@ -25,11 +26,11 @@ def connect(user_at_host, host_key=None, keep_alive=False,
         _SSHClient = paramiko.SSHClient
     ssh = _SSHClient()
     if host_key is None:
-       ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
     if _create_key is None:
         _create_key = create_key
 
-    if host_key is None:
+    if host_key is None and config.verify_host_keys is True:
         ssh.load_system_host_keys()
     else:
         keytype, key = host_key.split(' ', 1)
@@ -38,7 +39,7 @@ def connect(user_at_host, host_key=None, keep_alive=False,
             keytype=keytype,
             key=_create_key(keytype, key)
             )
-        
+
     # just let the exceptions bubble up to caller
     ssh.connect(
         hostname=host,