문제

import paramiko

client = paramiko.SSHClient()
client.load_system_host_keys()
ip = '192.168.100.6'
client.connect(ip, username='root', password='mima')
i, o, e = client.exec_command('apt-get install sl -y --force-yes')
print o.read(), e.read()
client.close()

i used this example.. it is working fine but i want after login server1 to login server2 i mean nested ssh .

도움이 되었습니까?

해결책

can't you call the ssh command from inside of your client.exec_command?
like:

client.exec_command('ssh user@host2 "apt-get install sl -y --force-yes"')

다른 팁

You exec the command "ssh" in the client, and not apt-get.

You can't really start a paramiko session on the client as long as your python program isn't there. The software you start using ssh must live on that machine.

Perhaps first scp a copy of your software, and start that using a parameter like -recursive_lvl = 1 ?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top