mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
utils/ssh: fix telnet connection
This fixes the ability to connect over telnet rather than SSH which was broken by commit 51db53d9 ssh: Back-port ssh_get_shell from devlib
This commit is contained in:
parent
afe3c16908
commit
a3d042e054
@ -40,19 +40,24 @@ logger = logging.getLogger('ssh')
|
|||||||
def ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeout=10, telnet=False, original_prompt=None):
|
def ssh_get_shell(host, username, password=None, keyfile=None, port=None, timeout=10, telnet=False, original_prompt=None):
|
||||||
_check_env()
|
_check_env()
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
|
extra_login_args = {}
|
||||||
while True:
|
while True:
|
||||||
if telnet:
|
if telnet:
|
||||||
if keyfile:
|
if keyfile:
|
||||||
raise ValueError('keyfile may not be used with a telnet connection.')
|
raise ValueError('keyfile may not be used with a telnet connection.')
|
||||||
conn = TelnetPxssh(original_prompt=original_prompt)
|
conn = TelnetConnection()
|
||||||
|
if original_prompt:
|
||||||
|
extra_login_args['original_prompt'] = original_prompt
|
||||||
|
if port is None:
|
||||||
|
port = 23
|
||||||
else: # ssh
|
else: # ssh
|
||||||
conn = pxssh.pxssh()
|
conn = pxssh.pxssh()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if keyfile:
|
if keyfile:
|
||||||
conn.login(host, username, ssh_key=keyfile, port=port, login_timeout=timeout)
|
conn.login(host, username, ssh_key=keyfile, port=port, login_timeout=timeout, **extra_login_args)
|
||||||
else:
|
else:
|
||||||
conn.login(host, username, password, port=port, login_timeout=timeout)
|
conn.login(host, username, password, port=port, login_timeout=timeout, **extra_login_args)
|
||||||
break
|
break
|
||||||
except EOF:
|
except EOF:
|
||||||
timeout -= time.time() - start_time
|
timeout -= time.time() - start_time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user