From 66835389c50a949f1910a22a37c52a6e9d3b953f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 30 Sep 2019 13:54:29 -0500 Subject: [PATCH] mgr/ssh: use ssh identity from config-key, if present Signed-off-by: Sage Weil --- src/pybind/mgr/ssh/module.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pybind/mgr/ssh/module.py b/src/pybind/mgr/ssh/module.py index 8f58349fcd8f9..6ae9f22df9e6e 100644 --- a/src/pybind/mgr/ssh/module.py +++ b/src/pybind/mgr/ssh/module.py @@ -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)) -- 2.39.5