Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by chrestomanci (Priest)
on Jan 26, 2012 at 11:47 UTC ( [id://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 (Canon) 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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://950076]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-20 00:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found