Merge pull request #16148 from privateip/working
fixes issues with authenticating using ssh-agent for ios devices
This commit is contained in:
commit
596b32f31e
2 changed files with 10 additions and 2 deletions
|
@ -77,9 +77,14 @@ class Cli(object):
|
||||||
key_filename = self.module.params['ssh_keyfile']
|
key_filename = self.module.params['ssh_keyfile']
|
||||||
timeout = self.module.params['timeout']
|
timeout = self.module.params['timeout']
|
||||||
|
|
||||||
|
allow_agent = (key_filename is not None) or (key_filename is None and password is None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.shell = Shell(kickstart=False, prompts_re=CLI_PROMPTS_RE, errors_re=CLI_ERRORS_RE)
|
self.shell = Shell(kickstart=False, prompts_re=CLI_PROMPTS_RE,
|
||||||
self.shell.open(host, port=port, username=username, password=password, key_filename=key_filename, timeout=timeout)
|
errors_re=CLI_ERRORS_RE)
|
||||||
|
self.shell.open(host, port=port, username=username,
|
||||||
|
password=password, key_filename=key_filename,
|
||||||
|
allow_agent=allow_agent, timeout=timeout)
|
||||||
except ShellError:
|
except ShellError:
|
||||||
e = get_exception()
|
e = get_exception()
|
||||||
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))
|
msg = 'failed to connect to %s:%s - %s' % (host, port, str(e))
|
||||||
|
|
|
@ -27,6 +27,7 @@ except ImportError:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import paramiko
|
import paramiko
|
||||||
|
from paramiko.ssh_exception import AuthenticationException
|
||||||
HAS_PARAMIKO = True
|
HAS_PARAMIKO = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_PARAMIKO = False
|
HAS_PARAMIKO = False
|
||||||
|
@ -111,6 +112,8 @@ class Shell(object):
|
||||||
self.shell.settimeout(timeout)
|
self.shell.settimeout(timeout)
|
||||||
except socket.gaierror:
|
except socket.gaierror:
|
||||||
raise ShellError("unable to resolve host name")
|
raise ShellError("unable to resolve host name")
|
||||||
|
except AuthenticationException:
|
||||||
|
raise ShellError('Unable to authenticate to remote device')
|
||||||
|
|
||||||
if self.kickstart:
|
if self.kickstart:
|
||||||
self.shell.sendall("\n")
|
self.shell.sendall("\n")
|
||||||
|
|
Loading…
Reference in a new issue