Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Is Net::SSH::Expect a thread-safe module?

by chrestomanci (Priest)
on Jan 26, 2012 at 11:47 UTC ( #950076=note: print w/ replies, xml ) Need Help??


in reply to Is Net::SSH::Expect a thread-safe module?

How are you using SSH with threads?

In my experience it is never safe to use threads (or forks) with any form of SSH if you plan to create a connection before creating child threads, and then using that connection in multiple children.

The reason is that like any well engineered security product, ssh (RFC 4251) will include protection against replay attacks, via some sort of sequence number. If you start an ssh connection in the parent, and then create child threads, then both parent and child will have copies of the connection object, with a sequence number. If both parent and child (or multiple children) then use their connections to talk to the server, then the ssh demon on the server will see the sequence number go backwards which would normally only happen if a cracker was attempting a replay attack, so the server will close or otherwise reject the connection.


Comment on Re: Is Net::SSH::Expect a thread-safe module?
Replies are listed 'Best First'.
Re^2: Is Net::SSH::Expect a thread-safe module?
by salva (Abbot) on Jan 26, 2012 at 12:38 UTC
    In my experience it is never safe to use threads (or forks) with any form of SSH if you plan to create a connection before creating child threads, and then using that connection in multiple children.

    Net::OpenSSH supports sharing the connection between different threads or processes.

      Wow....!

      Net::OpenSSH is pretty awesome. I can use threads with this module and able to complete my tasks as well.

      Thank you very much salva and PerlMonks once again.

      Thanks,
      Ashok
      it hardcodes /dev/nul
        So...?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-08-04 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (62 votes), past polls