简体   繁体   中英

REG:Authentication failed for user in Robot framework

I want to use SSHLibrary to connect remote server.

*** Settings ***
Library  SSHLibrary

*** Test Cases ***
Connection
    ${RemoteServer}=    openconnection    127.0.0.1    port=2123
    login    127.0.0.1    gfi    
    ${username}=    Executecommand    pwd

But i am getting error as authentication failed

TRACE : Arguments: [ '127.0.0.1' | port=2123 ]
TRACE : Return: 1
INFO  : ${RemoteServer} = 1
TRACE : Arguments: [ '127.0.0.1' | 'gfi' | delay='0.5 seconds' ]
INFO  : Logging into '127.0.0.1:2123' as '127.0.0.1'.
DEBUG : Adding ssh-ed25519 host key for [127.0.0.1]:2123: 56cde5c5d3a8494218b68ed41b4e837d
FAIL  : Authentication failed for user '127.0.0.1'.
DEBUG : 
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\SSHLibrary\library.py", line 914, in login
    is_truthy(look_for_keys), delay, proxy_cmd)
  File "c:\python27\lib\site-packages\SSHLibrary\library.py", line 973, in _login
    raise RuntimeError(e)
Ending test:   Launchvm.Launchvm.Connection

This is first time i am using SSHLibrary .Does it require any preconditions to use SSHLibrary. Can someone help how to solve authentication failed.

You have to take a look at the arguments for SSHLibrary - Login keyword.
As seen in the documentation Login first argument is username .
However, in your code you give 127.0.0.1 as username.
login 127.0.0.1 gfi
And I assume that is not the username.

You can also see this in the log message, that it try to login 127.0.0.1:2123 as 127.0.0.1 .
INFO : Logging into '127.0.0.1:2123' as '127.0.0.1'.

If you update the code and call login keyword with username and password as expected, it should run fine.
login <username> <password>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM