in reply to why timeout not working in Net::OpenSSH
The problem is that Ssh doesn't have a lot of options when it comes to responding to a timeout. Checkout the Timeouts section of the documentation to see there are really two options.
The first and default option is to close down the socket the remote system is using for input. In the ideal case the remote is configured to recognize this situation and terminate all running processes associated with the login. Clearly that's not happening on your remote, at least not while it's executing "sleep 10".
The other option which you can enable, will terminate all connections to the remote and immediately continue the execution of your local script. The downside with this is that the remote script may continue executing, and you wont capture any of its output. To enable this option change your params to:
You should see this error printed by your script:
user => $user,
port => '22',
kill_ssh_on_timeout => 1);
operation didn't complete successfully: ssh slave failed: timed out at