Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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?
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.

      it hardcodes /dev/nul
        So...?
      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

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 romping around the Monastery: (8)
As of 2014-12-28 09:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (180 votes), past polls