Пишут, что стандартная, работающая конструкция, но у меня не работает - выдает ошибку:
Secsh channel 1 open FAILED: : Resource shortage
import paramiko
jhost = '10.250.10.85'
juser = 'frodo'
jsecret = 'hdhdhdhdgfu#5'
jport = 22
dhost = '10.255.25.101'
lhost = '127.0.0.1'
duser = 'basy'
dsecret = 'jtyuk4#yU'
dport = 22
jumpHost=paramiko.SSHClient()
jumpHost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
jumpHost.connect(hostname=jhost, username=juser, password=jsecret, port=jport)
jumpHostTransport = jumpHost.get_transport()
dest_addr = (dhost, 22)
local_addr = (lhost, 22)
jumpHostChannel = jumpHostTransport.open_channel('direct-tcpip', dest_addr, local_addr)
destHost=paramiko.SSHClient()
destHost.set_missing_host_key_policy(paramiko.AutoAddPolicy())
destHost.connect(hostname=dhost, username=duser, password=dsecret, sock=jumpHostChannel)
destHostAgentSession = destHost.get_transport().open_session()
paramiko.agent.AgentRequestHandler(destHostAgentSession)
stdin, stderr, stdout = destHost.exec_command("show version")
print(stdout.read())
print(stderr.read())
destHost.close()
jumpHost.close()
-
Вопрос задан
-
43 просмотра