On Linux & Solaris 10, the following code works but if it is Solaris 11, it throws the following error message paramiko.ssh_exception.AuthenticationException: Authentication failed.
. The credentials/authentication details are correct. The host, username and password are all correct but for some reason it complains about Authentication failure. I know that Solaris 11 has much more beefed up security. Is there any thing else I need to add to my code to get this to work? (more details below):
def setup_remote_gateway_client_connection(self, gateway_host, gateway_username, gateway_password, client_host, client_username, client_password, gateway_port=22, client_port=22):
self.gateway_host=paramiko.SSHClient()
self.gateway_host.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.gateway_host.connect(gateway_host, username=gateway_username, password=gateway_password )
gateway_transport = self.gateway_host.get_transport()
src_addr = (gateway_host, gateway_port)
dest_addr = (client_host, client_port)
gateway_channel = gateway_transport.open_channel("direct-tcpip", dest_addr, src_addr)
client_host=paramiko.SSHClient()
client_host.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client_host.connect(client_host, username=client_username, password=client_password, sock=gateway_channel)
stdin, stdout, stderr = client_host.exec_command('ls -la')
for line in stdout.read().split(b'\n'):
print(str(line))
stdin, stdout, stderr = client_host.exec_command('hostname')
for line in stdout.read().split(b'\n'):
print(str(line))
client_host.close()
self.gateway_host.close()
Upon execution, I get the following:
fixture.py:28: in setup_remote_gateway_client_connection
client_host.connect(client_host, username=client_username, password=client_password, sock=gateway_channel)
/usr/local/lib/python3.10/site-packages/paramiko/client.py:450: in connect
self._auth(
/usr/local/lib/python3.10/site-packages/paramiko/client.py:781: in _auth
raise saved_exception
/usr/local/lib/python3.10/site-packages/paramiko/client.py:768: in _auth
self._transport.auth_password(username, password)
/usr/local/lib/python3.10/site-packages/paramiko/transport.py:1564: in auth_password
return self.auth_handler.wait_for_response(my_event)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <paramiko.auth_handler.AuthHandler object at 0x107691ae0>
event = <threading.Event object at 0x107691a20>
def wait_for_response(self, event):
max_ts = None
if self.transport.auth_timeout is not None:
max_ts = time.time() + self.transport.auth_timeout
while True:
event.wait(0.1)
if not self.transport.is_active():
e = self.transport.get_exception()
if (e is None) or issubclass(e.__class__, EOFError):
e = AuthenticationException("Authentication failed.")
raise e
if event.is_set():
break
if max_ts is not None and max_ts <= time.time():
raise AuthenticationException("Authentication timeout.")
if not self.is_authenticated():
e = self.transport.get_exception()
if e is None:
e = AuthenticationException("Authentication failed.")
# this is horrible. Python Exception isn't yet descended from
# object, so type(e) won't work. :(
if issubclass(e.__class__, PartialAuthentication):
return e.allowed_types
> raise e
E paramiko.ssh_exception.AuthenticationException: Authentication failed.
/usr/local/lib/python3.10/site-packages/paramiko/auth_handler.py:259: AuthenticationException