From a1bf062d42247bc2d675133e3a6d61ad4f26872f Mon Sep 17 00:00:00 2001 From: DiptoChakrabarty Date: Mon, 24 May 2021 19:23:20 +0530 Subject: [PATCH] use subprocess instead of os.system --- paramiko_tutorial/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/paramiko_tutorial/client.py b/paramiko_tutorial/client.py index dc2d840..c868269 100644 --- a/paramiko_tutorial/client.py +++ b/paramiko_tutorial/client.py @@ -1,5 +1,6 @@ """Client to handle connections and actions executed against a remote host.""" from os import system +import subprocess as sp from typing import List from paramiko import AutoAddPolicy, RSAKey, SSHClient @@ -65,7 +66,7 @@ def _get_ssh_key(self): def _upload_ssh_key(self): try: - system( + sp.getoutput( f"ssh-copy-id -i {self.ssh_key_filepath}.pub {self.user}@{self.host}>/dev/null 2>&1" ) LOGGER.info(f"{self.ssh_key_filepath} uploaded to {self.host}")