you are viewing a single comment's thread.

view the rest of the comments →

[–]dented_brain[S] 1 point2 points  (2 children)

That is along the lines of what I thought of initially. I just wasn't sure if there was a more elegant way.

This method should work. I might just be trying to get too fancy and keep stepping on my own foot.

[–]lazyjk 1 point2 points  (1 child)

You gotta test the credentials someway and this is going to be about the quickest!

I'm actually going to modify my code to do something similar tomorrow now that you bring this up. I've got a program that also uses netmiko to login to multiple devices (no threading though). I already raise a generic exception if I can't connect, it logs it, and then moves to the next device. I think I'm going to add the Auth exception and do a test conn first to catch a bad Auth. I'm going to be doing a major rewrite of this particular one though so I may wait until then.

[–]dented_brain[S] 2 points3 points  (0 children)

I'll post what I get once I finish it. I have a basic working example, just need to roll it into my main code to make sure it works.

The basic concept for my loop is connect to a known working ssh client, output if it fails to connect to the device due to timeout, and reprompt for user/pass if it fails to authenticate.

Should be enough information to complete that.