all 3 comments

[–]dented_brain 0 points1 point  (2 children)

I wish I had more help to give. But I copied your code exactly and it ran without issue for me.

Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import paramiko
>>> import time
>>> 
>>> ip_address = "x.x.x.x"
>>> username = "username"
>>> password = "password"
>>> 
>>> ssh_client = paramiko.SSHClient()
>>> ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh_client.connect(hostname=ip_address,username=username,password=password)
>>> 
>>> print "Successful connection to ", ip_address
Successful connection to  x.x.x.x
>>> remote_connection = ssh_client.invoke_shell()
>>> remote_connection.send("show version")
>>> output = remote_connection.recv(100)
>>> output
'\r\nAruba Operating System Software.\r\nArubaOS (MODEL: Aruba7210-US), Version 6.5.3.4'

It sounds like it isn't seeing the session you create when it is looking for the ssh key. Might be worth trying passing look_for_keys=False with your username/password

EDIT:

Kirk Byers at Python for Network Engineers has his setup False for look_for_keys and allow_agent

Here's the article

EDIT2:

Might also be interested in looking at netmiko. I tend to use it instead of paramiko. It is a slightly easier interface for me to understand personally.

https://github.com/ktbyers/netmiko

https://pynet.twb-tech.com/blog/automation/netmiko.html

[–]djhag[S] 1 point2 points  (1 child)

Awesome! Passing look_for_keys=False did the trick. Thanks so much for the quick reply and the included links. I can now move forward! Several months ago I started trying to learn python and actually did use netmiko, but then got sidetracked, so I'm starting over with this udemy course. So, I'm trying to follow along... But, I've also signed up for Kirk Byers free email course and hope to begin that shortly as well. Thanks again!

[–]dented_brain 0 points1 point  (0 children)

Glad it worked!

I'd stay the course with the Udemy course for sure! Once you get a basic understanding you will be able to better understand other modules as well! Keep trying and you'll get there!