]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra.connection: Look for 'ssh_key' in config 1812/head
authorZack Cerza <zack@redhat.com>
Wed, 1 Feb 2023 19:43:43 +0000 (12:43 -0700)
committerZack Cerza <zack@redhat.com>
Tue, 7 Feb 2023 17:55:38 +0000 (10:55 -0700)
On systems where SSH is configured using ~/.ssh/config.d/, we don't have
a great way of locating and processing the full configuration, so we
might not find the correct key to use. Allow the user to specify one key
to use for all test nodes if they wish.

Signed-off-by: Zack Cerza <zack@redhat.com>
docs/siteconfig.rst
teuthology/config.py
teuthology/orchestra/connection.py

index 5bc98e98d6f415e62b2de619f19b87904c6e8b3d..a80abb0a412114cc9744e55fa1a0283a2a79bd56 100644 (file)
@@ -226,6 +226,10 @@ Here is a sample configuration with many of the options set and documented::
     conserver_master: conserver.front.sepia.ceph.com
     conserver_port: 3109
 
+    # Optionally use a specific SSH private key to connect to test nodes.
+    # Takes precedence over any entries in ~/.ssh/config.
+    ssh_key: ~/.ssh/my_key.rsa
+
     # Settings for [nsupdate-web](https://github.com/zmc/nsupdate-web)
     # Used by the [libcloud](https://libcloud.apache.org/) backend
     nsupdate_url: http://nsupdate.front.sepia.ceph.com/update
index 5fe02de20247ccef5557d2a95f362f527a4910cd..d499e767276af6db5deb4eebd53cd66f2bfd1c09 100644 (file)
@@ -191,6 +191,7 @@ class TeuthologyConfig(YamlConfig):
         },
         'rocketchat': None,
         'sleep_before_teardown': 0,
+        'ssh_key': None,
     }
 
     def __init__(self, yaml_path=None):
index d9706b59599d6dc98fbb6a37ae50245d28fb384d..1e66e8f87af09e074db3fcc581bd0c16d1ab329f 100644 (file)
@@ -79,8 +79,9 @@ def connect(user_at_host, host_key=None, keep_alive=False, timeout=60,
         timeout=timeout
     )
 
+    key_filename = key_filename or config.ssh_key
     ssh_config_path = os.path.expanduser("~/.ssh/config")
-    if os.path.exists(ssh_config_path):
+    if not key_filename and os.path.exists(ssh_config_path):
         ssh_config = paramiko.SSHConfig()
         ssh_config.parse(open(ssh_config_path))
         opts = ssh_config.lookup(host)