]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/ssh: use ssh identity from config-key, if present
authorSage Weil <sage@redhat.com>
Mon, 30 Sep 2019 18:54:29 +0000 (13:54 -0500)
committerSage Weil <sage@redhat.com>
Fri, 4 Oct 2019 19:37:28 +0000 (14:37 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/pybind/mgr/ssh/module.py

index 8f58349fcd8f9559a215abc8990b23a2b93e9157..6ae9f22df9e6eb13fd6e8647411ce3dcfe74eb83 100644 (file)
@@ -260,6 +260,23 @@ class SSHOrchestrator(MgrModule, orchestrator.Orchestrator):
                     ssh_config_fname))
             ssh_options = "-F {}".format(ssh_config_fname)
 
+        # identity
+        ssh_key = self.get_store("ssh_identity_key")
+        ssh_pub = self.get_store("ssh_identity_pub")
+        if ssh_key and ssh_pub:
+            tkey = tempfile.NamedTemporaryFile()
+            tkey.write(ssh_key.encode('utf-8'))
+            os.fchmod(tkey.fileno(), 0o600);
+            tkey.flush() # make visible to other processes
+            tpub = tempfile.NamedTemporaryFile()
+            os.fchmod(tpub.fileno(), 0o600);
+            tpub.write(ssh_pub.encode('utf-8'))
+            tpub.flush() # make visible to other processes
+            conn.temp_files += [tkey, tpub]
+            if not ssh_options:
+                ssh_options = ''
+            ssh_options += '-i {}'.format(tkey.name)
+
         self.log.info("opening connection to host '{}' with ssh "
                 "options '{}'".format(host, ssh_options))