Hi Everyone,
I need help... :'(
When referring to:
I should be able to just specify the device name and connect so I started with ansible and built out a simple playbook to tell me the device version but the connections always failed.
Then I moved my troubleshooting to the python module itself as I can connect on ssh and the netconf port with no issue in Ubuntu and the keys were loaded in memory.
Notes
- Fresh Ubuntu 20.04 LTS environment from the Windows store.
- Network devices username is configured in ~/.ssh/config
- Our environment is ssh keys only (no password auth)
- SSH works directly with key loaded in memory
- netconf is running and can connect with :
ssh -p 830 -s netconf
Version Info
- OS: Ubuntu 20.04 on WSL2
- Python: 3.8.10 (Default with distro)
- PIP: 21.1.3
- Ansible: 2.10.11
- junos-eznc: 2.6.1
PIP Packages Installed
# python3 -m pip list
# Note: all installed with --user
Package Version ---------------------- -------------------- ansible 2.10.7 ansible-base 2.10.11 asn1crypto 1.4.0 attrs 19.3.0 Automat 0.8.0 bcrypt 3.2.0 blinker 1.4 certifi 2019.11.28 cffi 1.14.5 chardet 3.0.4 Click 7.0 cloud-init 21.2 colorama 0.4.3 command-not-found 0.3 configobj 5.0.6 constantly 15.1.0 cryptography 2.8 dbus-python 1.2.16 diceware 0.9.6 distro 1.4.0 distro-info 0.23ubuntu1 entrypoints 0.3 enum34 1.1.10 httplib2 0.14.0 hyperlink 19.0.0 idna 2.8 importlib-metadata 1.5.0 incremental 16.10.1 ipaddress 1.0.23 Jinja2 2.10.1 jsonpatch 1.22 jsonpointer 2.0 jsonschema 3.2.0 junos-eznc 2.6.1 jxmlease 1.0.3 keyring 18.0.1 language-selector 0.1 launchpadlib 1.10.13 lazr.restfulclient 0.14.2 lazr.uri 1.0.3 lxml 4.6.3 MarkupSafe 1.1.0 monotonic 1.6 more-itertools 4.2.0 ncclient 0.6.9 netaddr 0.8.0 netconf 2.1.0 netifaces 0.10.4 oauthlib 3.1.0 packaging 21.0 paramiko 2.7.2 pexpect 4.6.0 pip 21.1.3 pyasn1 0.4.2 pyasn1-modules 0.2.1 pycparser 2.20 PyGObject 3.36.0 PyHamcrest 1.9.0 PyJWT 1.7.1 pymacaroons 0.13.0 PyNaCl 1.3.0 pyOpenSSL 19.0.0 pyparsing 2.4.7 pyrsistent 0.15.5 pyserial 3.4 python-apt 2.0.0+ubuntu0.20.4.5 python-debian 0.1.36ubuntu1 pytils 0.3 PyYAML 5.3.1 requests 2.22.0 requests-unixsocket 0.2.0 scp 0.13.5 SecretStorage 2.3.1 selectors 0.0.14 service-identity 18.1.0 setuptools 45.2.0 simplejson 3.16.0 six 1.14.0 sos 4.1 ssh-import-id 5.10 sshutil 1.5.0 systemd-python 234 transitions 0.8.8 Twisted 18.9.0 ubuntu-advantage-tools 27.0 ufw 0.36 unattended-upgrades 0.1 urllib3 1.25.8 user-agent 0.1.9 wadllib 1.3.3 weblib 0.1.30 wheel 0.34.2 xmltodict 0.12.0 yamlordereddictloader 0.4.0 zipp 1.0.0 zope.interface 4.7.1
Environment Setup Notes
python3 -m pip install --upgrade pip python3 -m pip install --user \ ansible==2.10.7 \ paramiko \ junos-eznc \ xmltodict \ asn1crypto \ bcrypt \ cffi \ cryptography \ enum34 \ idna \ ipaddress \ Jinja2 \ jxmlease \ lxml \ MarkupSafe \ ncclient \ netaddr \ pyasn1 \ pycparser \ PyNaCl \ pyserial \ PyYAML \ scp \ selectors \ six \ netconf ansible-galaxy collection install \ juniper.device \ junipernetworks.junos
However when running a simple script:
# Python 3 from jnpr.junos import Device from getpass import getpass import sys import jnpr.junos.exception hostname = input("Device hostname: ") try: # NETCONF session over SSH with Device(host=hostname) as dev: print (dev.facts) except Exception as err: print (err) sys.exit(1)
I get this error and it doesn't seem to matter if I specify user, pass, keyfile, etc the results are always the same. This is the same error I receive on Ansible even I use the connection as 'local'.
ConnectAuthError
When I force specify the variables still no luck and get the same error.
Device(host=hostname, key_password='pass', user='username', ssh_private_key_file='/home/user/id_rsa')
I feel like I'm missing something very simple but I've hit a wall... If anyone might know it would be a huge help.
In the meantime this has given me a great challenge so far so I will keep bashing away at this and if I find the solution I will be sure to reply encase it can help others unless someone can push me in the right direction.
Thanks everyone!
No comments:
Post a Comment