cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
8746
Views
7
Helpful
8
Replies

pyATS genie cannot connect via ssh

boesch
Level 1
Level 1

Hi,

Just started to play around with pyATS and genie.

But I cannot connect to the switch via ssh.

 

My testbed.yml file looks like this:

devices:
  as-test2:
    connections:
      vty:
        ip: 172.21.31.6
        protocol: ssh
    credentials:
      default:
        password: '%ASK{}'
        username: chris
    os: iosxe
    type: iosxe
    series: cat9k
    platform: cat9k

Then I try to parse "show version" and the connect fails:

./bin/genie -vvv parse "show version" --testbed-file testbed.yml 
loading yaml file /Users/cb/networking/genie/testbed.yml
Deriving testbed name ...
Enter default password for device as-test2: 
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Using a default key as pyATS configuration under [secrets] string.key was not specified.
Credential credentials not found, trying default ...
Credential credentials not found, trying default ...

2020-10-08 11:04:33,535: %UNICON-INFO: +++ as-test2 logfile /tmp/as-test2-cli-20201008T110433535.log +++

2020-10-08 11:04:33,536: %UNICON-INFO: +++ Unicon plugin iosxe/cat9k +++
Connection closed by 172.21.31.6 port 22


2020-10-08 11:04:42,574: %UNICON-INFO: +++ connection to spawn: ssh -l chris 172.21.31.6, id: 4682891904 +++

2020-10-08 11:04:42,574: %UNICON-INFO: connection to as-test2
  0%|                                                                                                                                                                             | 0/1 [00:00<?, ?it/s]Issue with the parser show version


Traceback (most recent call last):
  File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
  File "src/genie/conf/base/device.py", line 551, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 582, in genie.conf.base.device.Device._get_parser_output
TypeError: device is not connected, output must be provided.
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  2.30it/s]

ssh access in general is working via terminal, and also username and password are correct.

In syslog it generates messages:

%SEC_LOGIN-4-LOGIN_FAILED: Login failed [user: Invalid-Credentials] [Source: 172.23.8.241] [localport: 22] [Reason: Login Authentication Failed]

Has someone an idea what could be the reason.

Kind regards, Christian

1 Accepted Solution

Accepted Solutions

Yes..you are right.  Are you in a position to spin up a new virtual environment or use the pyATS Docker image and try?   It looks like your testbed file is good and if you can ssh from that same system I would try to determine if maybe I had an issue with my environment.

View solution in original post

8 Replies 8

Claudia de Luna
Spotlight
Spotlight

HI @boesch 

 

Can you try replacing vty with your cli in your testbed file?

Also, what version of pyATS are you using.

 

Here is an Intro Repo that may be of help:

https://github.com/cldeluna/interop2020_pyats_intro

 

 

Hi Claudia,

I've already tried changing vty to cli with no effect.

I have pyats version 20.9.

 

good..thx for the info.

 

Is the hostname as-test2 the actual hostname of the device?  Those should match exactly

 

here is what I get when the hostname does not match:

(interop2020_pyats_intro) claudia@Claudias-iMac interop2020_pyats_intro % pyats parse "show version" --testbed-file test_tb.yml --output TEST
Enter default password for device as-test2: 
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  2.64it/s]
+==============================================================================+
| Genie Parse Summary for as-test2                                             |
+==============================================================================+
|  Failed to connect to as-test2                                               |
|  -  Log: TEST/connection_as-test2.txt                                        |
|------------------------------------------------------------------------------|
|  Could not parse 'show version'                                              |
|  -  Exception:      TEST/as-test2_show-version_exception.txt                 |
|  -  Device Console: TEST/as-test2_show-version_console.txt                   |
|------------------------------------------------------------------------------|

 

Here is what I get when it does:

(interop2020_pyats_intro) claudia@Claudias-iMac interop2020_pyats_intro % pyats parse "show version" --testbed-file test_tb.yml --output TEST
Enter default password for device celebes-sw05: 
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.30it/s]
+==============================================================================+
| Genie Parse Summary for celebes-sw05                                         |
+==============================================================================+
|  Connected to celebes-sw05                                                   |
|  -  Log: TEST/connection_celebes-sw05.txt                                    |
|------------------------------------------------------------------------------|
|  Parsed command 'show version'                                               |
|  -  Parsed structure: TEST/celebes-sw05_show-version_parsed.txt              |
|  -  Device Console:   TEST/celebes-sw05_show-version_console.txt             |
|------------------------------------------------------------------------------|

(interop2020_pyats_intro) claudia@Claudias-iMac interop2020_pyats_intro % 

 

 

Here is the testbed file I used the second time (that worked):

---
devices:
  celebes-sw05:
    connections:
      vty:
        ip: 10.1.10.216
        protocol: ssh
    credentials:
      default:
        password: '%ASK{}'
        username: cisco
    os: iosxe
    type: iosxe
    series: cat9k
    platform: cat9k

So you are on the right track!

 

Yes the hostname is exactly the same:

as-test2#sh run | in hostname
hostname as-test2

In your unsuccessful example you can at least connect.

My problem is that the connection cannot be established:

Traceback (most recent call last):
  File "src/genie/cli/commands/parser.py", line 339, in genie.cli.commands.parser.ParserCommand.parse
  File "src/genie/conf/base/device.py", line 551, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 582, in genie.conf.base.device.Device._get_parser_output
TypeError: device is not connected, output must be provided.

Yes..you are right.  Are you in a position to spin up a new virtual environment or use the pyATS Docker image and try?   It looks like your testbed file is good and if you can ssh from that same system I would try to determine if maybe I had an issue with my environment.

If you have done the DEVNET Associate 1.0 course then follow this:-

 

1. See the steps in LAB-7.0.3---- PART-2, STEP-4 

2. Do those steps again before pushing the command "genie parse "show ip interface brief" --testbed-file yaml/testbed.yml --devices CSR1kv"

 

3. It shows an error because whenever you start CSR1kv it changes the RSA fingerprint in the backend and when you try to connect with the tesbed.yml credentials it refuses the connection due to RSA mismatch.

 

4. Follow my point no-1 and delete the existing RSA Fingerprint and update with the new one and again push the command "show ip interface brief" --testbed-file yaml/testbed.yml --devices CSR1kv" it will work for sure.

 

5. You can see the screenshots for further reference.

 

Regards,

Satya Prakash Dhal

I had the same issue and following the steps from SPDCool solved it, thank you!

your screenshots definitely helped!! thank you