Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library raises Authentication failure, but host accepted it #374

Closed
roulier opened this issue Dec 22, 2020 · 4 comments
Closed

Library raises Authentication failure, but host accepted it #374

roulier opened this issue Dec 22, 2020 · 4 comments

Comments

@roulier
Copy link

roulier commented Dec 22, 2020

Hello,

I have experienced issues with the latest version 3.6.0 that I do not have with version 3.5.1

I manage to open a connection with "open_connection"
open_connection(ip, port=port, timeout=timeout, prompt="#")

but "login" systematically fails
self.login("root", "")

as follows
Traceback (most recent call last): File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/pythonclient.py", line 123, in _login transport.auth_none(username) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/paramiko/transport.py", line 1446, in auth_none return self.auth_handler.wait_for_response(my_event) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/paramiko/auth_handler.py", line 240, in wait_for_response raise AuthenticationException("Authentication timeout.") paramiko.ssh_exception.AuthenticationException: Authentication timeout.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/abstractclient.py", line 202, in login self._login(username, password, allow_agent, look_for_keys, proxy_cmd, read_config_host, jumphost_connection) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/pythonclient.py", line 141, in _login raise SSHClientException SSHLibrary.abstractclient.SSHClientException

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/library.py", line 1053, in _login login_output = login_method(username, *args) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/abstractclient.py", line 206, in login % self._decode(username)) SSHLibrary.abstractclient.SSHClientException: Authentication failed for user 'root'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "qemu_investigation.py", line 7, in <module> foo.connect_board() File "/media/workdir/iot-bridge-projectconf/verification/test_lib/fr_iotb_environment/Ssh.py", line 56, in connect_board raise e File "/media/workdir/iot-bridge-projectconf/verification/test_lib/fr_iotb_environment/Ssh.py", line 49, in connect_board self.login(self.sut.user, self.sut.password) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/library.py", line 982, in login is_truthy(look_for_keys), delay, proxy_cmd, is_truthy(read_config_host), jumphost_connection) File "/home/galaxy/.pyenv/versions/py369-ssh/lib/python3.6/site-packages/SSHLibrary/library.py", line 1059, in _login raise RuntimeError(e) RuntimeError: Authentication failed for user 'root'.

On the host side, login is seen with a journalctl -f
sshd[2307]: Accepted none for root from 192.168.1.26 port 52926 ssh2

As I mentionned, with version 3.5.1 eveything works fine (I switched version several times with pip3 install robotframework-sshlibrary==3.5.1 / pip3 install robotframework-sshlibrary==3.6.0)

The host I am trying to connect to is an embedded system with linux, accessible with "root" and no password. I am not sure I can give you much details about the host, because this is work-related. Anyway, I figured this might reveal a problem in the 3.6.0 version of SSHLibrary.

Best regards

@mihaiparvu
Copy link
Contributor

I've tried to reproduce this but without success, for my environment it works without problem. Did you try to connect using the Robot Framework test data syntax:

Open Connection    ${host}
Login              root

Note there's no need to put "" if there is no password set.

@roulier
Copy link
Author

roulier commented Jan 6, 2021

Thank you for your answer. I tried using RobotFramework directly (instead of using my python library), and as you suggested, without giving the empty password.

The issue is now clearer :

With

Open Connection ${host}
Login root

everything is fine, whereas with

Open Connection ${host}
Login root ${emptystring}

I get the error described previously.
Note : I used

*** Variables ***
${empty_string} = \

When I got back to robotframework-sshlibrary==3.5.1 , everything is fine in both cases.

Conclusion : version 3.6.0 no longer supports explicit empty password.

I do not know if this is considered as a real issue; but I can manage a workaround on my end, so thanks !

@tw39124-1
Copy link

tw39124-1 commented Dec 14, 2021

I also have this issue, and the workaround of "go back to robotframework-sshlibrary==3.5.1" is not really a sufficient fix. It seems there is an actual bug in robotframework-sshlibrary preventing password-less authentication from working.

Having looked through the code for v3.8.0 I seem to have tracked it down to these lines in the login() function in abstractclient.py:

if not password and not allow_agent:
    password = self._encode(password)

This code seems to be turning the value of None (i.e. the Python NoneType) into the bytestring b'None', which then causes the downstream code in _login() in pythonclient.py to fail to detect and handle a password-less auth.

If password is None, why would we want to attempt to encode the string 'None' into a byte array as the password? Shouldn't it be:

if password and not allow_agent:
    password = self._encode(password)

Can someone with more knowledge of this library confirm these findings? Making this change locally seems to allow me to log in without a password using robotframework-sshlibrary==3.8.0.

@JianZhou12345678
Copy link

Hello,
I want to connect to my router via ssh. It is found that you can use linux commands such as "ssh admin@192.168.1.1 -p 2222" to enter without entering a password
I have installed robotframework==3.8.0, but still find the error "Authentication failed for user 'admin'", I don't know how to solve it...

My test.robot file as below:
*** Settings ***
Library SSHLibrary WITH NAME Zeus

*** Variables ***
${ssh_ip} 192.168.1.1
${ssh_port} 2222
${ssh_username} admin

*** Test Cases ***
SSH Sample
Zeus.Open Connection host=${ssh_ip} port=${ssh_port}
${output} Zeus.Login username=${ssh_username}
Log ${output}
[Teardown] Zeus.Close Connection

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants