X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=modules%2Fopnfv%2Futils%2Fssh_utils.py;h=22727170b3b40ce5949f5aa1a7f3af7903a2835e;hb=2c776854979845daad2a91b62cb0403d27a8e352;hp=4c5ff5c1ba50252f65f0df0507718ddffc726300;hpb=32c30a6ce8c2f59d75f4c94fce9ed201437a554b;p=releng.git diff --git a/modules/opnfv/utils/ssh_utils.py b/modules/opnfv/utils/ssh_utils.py index 4c5ff5c1b..22727170b 100644 --- a/modules/opnfv/utils/ssh_utils.py +++ b/modules/opnfv/utils/ssh_utils.py @@ -49,9 +49,12 @@ def get_ssh_client(hostname, client = paramiko.SSHClient() else: client = ProxyHopClient() + proxy_password = proxy.get('password', None) + proxy_pkey_file = proxy.get('pkey_file', '/root/.ssh/id_rsa') client.configure_jump_host(proxy['ip'], proxy['username'], - proxy['password']) + proxy_password, + proxy_pkey_file) if client is None: raise Exception('Could not connect to client') @@ -115,6 +118,8 @@ class ProxyHopClient(paramiko.SSHClient): jh_ssh_key='/root/.ssh/id_rsa'): self.proxy_ip = jh_ip self.proxy_ssh_key = jh_ssh_key + self.local_ssh_key = os.path.join(os.getcwd(), + jh_ssh_key.split('/')[-1]) self.proxy_ssh = paramiko.SSHClient() self.proxy_ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.proxy_ssh.connect(jh_ip, @@ -138,8 +143,12 @@ class ProxyHopClient(paramiko.SSHClient): self.local_ssh_key) if get_file_res is None: raise Exception('Could\'t fetch SSH key from jump host') - proxy_key = (paramiko.RSAKey - .from_private_key_file(self.local_ssh_key)) + if self.proxy_ssh_key.split('/')[-1] == 'id_dsa': + proxy_key = (paramiko.DSSKey + .from_private_key_file(self.local_ssh_key)) + else: + proxy_key = (paramiko.RSAKey + .from_private_key_file(self.local_ssh_key)) self.proxy_channel = self.proxy_transport.open_channel( "direct-tcpip",