Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Problems with Net::OpenSSH

by chrestomanci (Priest)
on Nov 23, 2010 at 09:22 UTC ( [id://873139]=note: print w/replies, xml ) Need Help??


in reply to Problems with Net::OpenSSH

Will your router accept a public/private key pair for authentication instead of using password based auth?

A few years ago, I was controling a netapp storage device from perl, and I found that it would maintain a list of authorised public ssh keys. Once I had added my public key to it's keyring, I could then have my perl script connect using a private key, and without the need to handle password prompts. The connection went directly to a shell where typicaly my script would issue one command, capture the output and then dissconnect. This made that part of the script much simpler.

One issue to be aware of, is that the device I was connecting to did not like it if there was an SSH agent which offered several different keys until one was accepted. If the first key offered was not acceptable the connection got dropped, there was no possibility to try a different key or drop back to password based authentication, so when you test, you should add -a to your ssh command line.

Replies are listed 'Best First'.
Re^2: Problems with Net::OpenSSH
by aeaton1843 (Acolyte) on Nov 23, 2010 at 16:15 UTC

    Oh how I wish they did. Cisco didn't add that functionality until IOS 15.0.1(M1) or so. Most of our routers are still in the 12.x train. I am actually controlling some F5's with Net::SSH in the manner in which you are suggesting. It works very well except for one thing. I wrote this module as a threaded app with ithreads and Net::SSH isn't thread safe. I found thanks to this site that Net::SSH::Perl isn't thread safe either. What I may end up doing is moving all of the Cisco routers into code that uses Net::SSH::Perl and use parent/child forking. I suppose I never really found out whether Net::OpenSSH is thread safe. I went looking for it and never found the information.

      Net::OpenSSH is pure perl and does not use any globals, so it should be thread safe. Though I (BTW, I am the author) have never used it in threaded applications. IIRC, nobody have reported problems related to threads either.

      Anyway, Net::OpenSSH can be used asynchronously, you don't even need threads to handle connecting in parallel to several hosts. Check also Net::OpenSSH::Parallel.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://873139]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 07:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found