目的要先连接跳板机再连ssh
参考
import paramiko
vm = paramiko.SSHClient()
vm.set_missing_host_key_policy(paramiko.AutoAddPolicy())
vm.connect('172.16.255.180', username='root', password='12121')
vmtransport = vm.get_transport()
dest_addr = ('172.19.71.221', 22)
local_addr = ('172.16.255.180', 22)
vmchannel = vmtransport.open_channel("direct-tcpip", dest_addr, local_addr)
jhost = paramiko.SSHClient()
jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jhost.connect('172.19.71.221', username='root', password='12121', sock=vmchannel)
stdin, stdout, stderr = jhost.exec_command("ifconfig")
print(stdout.read())
jhost.close()
vm.close()