bugfix
This commit is contained in:
parent
5171ee6f9c
commit
91066d5b72
@ -6,10 +6,15 @@ from appPublic.myTE import tmpTml
|
|||||||
import asyncio, asyncssh, sys
|
import asyncio, asyncssh, sys
|
||||||
|
|
||||||
class SSHNode:
|
class SSHNode:
|
||||||
def __init__(self, host, username='root', port=22, jumpers=[]):
|
def __init__(self, host,
|
||||||
|
username='root',
|
||||||
|
port=22,
|
||||||
|
password=None,
|
||||||
|
jumpers=[]):
|
||||||
self.server2 = {
|
self.server2 = {
|
||||||
"host":host,
|
"host":host,
|
||||||
"username":username,
|
"username":username,
|
||||||
|
"password":password,
|
||||||
"port":port
|
"port":port
|
||||||
}
|
}
|
||||||
self.jumpers = jumpers
|
self.jumpers = jumpers
|
||||||
@ -20,20 +25,30 @@ class SSHNode:
|
|||||||
refconn = None
|
refconn = None
|
||||||
for j in self.jumpers:
|
for j in self.jumpers:
|
||||||
host = j['host']
|
host = j['host']
|
||||||
username = j['username']
|
username = j.get('username', 'root')
|
||||||
port = j['port']
|
port = j.get('port',22)
|
||||||
|
password= j.get('password', None)
|
||||||
|
if refconn:
|
||||||
|
refconn = await refconn.connect_ssh(host,
|
||||||
|
username=username,
|
||||||
|
password=password,
|
||||||
|
port=port)
|
||||||
|
else:
|
||||||
refconn = await asyncssh.connect(host,
|
refconn = await asyncssh.connect(host,
|
||||||
username=username,
|
username=username,
|
||||||
|
password=password,
|
||||||
port=port)
|
port=port)
|
||||||
self.jumper_conns.append(refconn)
|
self.jumper_conns.append(refconn)
|
||||||
|
|
||||||
host = self.server2['host']
|
host = self.server2['host']
|
||||||
username = self.server2['username']
|
username = self.server2.get('username', 'root')
|
||||||
port = self.server2['port']
|
port = self.server2.get('port',22)
|
||||||
|
password = self.server2.get('password', None)
|
||||||
if refconn:
|
if refconn:
|
||||||
return await refconn.connect_ssh(host,
|
return await refconn.connect_ssh(host,
|
||||||
username=username,
|
username=username,
|
||||||
port=port,
|
port=port,
|
||||||
|
password=password,
|
||||||
known_hosts=None)
|
known_hosts=None)
|
||||||
else:
|
else:
|
||||||
return await asyncssh.connect(host,
|
return await asyncssh.connect(host,
|
||||||
|
Loading…
Reference in New Issue
Block a user