From e34fc73d5518bcd8acb7b86a16c0cd9e253393b7 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Sun, 29 Oct 2023 09:37:06 +0100 Subject: Minor changes --- clusterman/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 clusterman/utils.py (limited to 'clusterman/utils.py') diff --git a/clusterman/utils.py b/clusterman/utils.py new file mode 100644 index 0000000..ad79bd2 --- /dev/null +++ b/clusterman/utils.py @@ -0,0 +1,13 @@ +import subprocess +from clusterman.config import CONF + +def ssh_exec(host,command,use_key=True): + user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"] + key_path=CONF["ssh"]["key_path"] + if use_key: + output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "-o", "PasswordAuthentication=no", "-i", CONF["ssh"]["key_path"],"{}@{}".format(user,ip), command]) + return output.decode("utf-8") + else: + output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "{}@{}".format(user,ip), command]) + return output.decode("utf-8") + -- cgit v1.2.3