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

Re: Net::SSH::Perl ConnectTimeout (ssh -o option)

by neilwatson (Priest)
on Aug 10, 2006 at 13:49 UTC ( #566623=note: print w/replies, xml ) Need Help??

in reply to Net::SSH::Perl ConnectTimeout (ssh -o option)

Looking at the source code, the ToDo file, reveals that this is not yet finished:
$Id: ToDo,v 1.22 2003/12/03 15:35:21 autarch Exp $ Add more tests to the test suite; add SSH2 tests. Fixes to SSH2 implementation: * get rid of dummy shell channel (if possible) * more documentation * anything currently marked XXX in the code Compatibility with NetScreen? Switch over to using Crypt::RSA for SSH1 RSA implementation? SSH2 RSA keys now use Crypt::RSA; at this point it might just be too much extra baggage to try to force people to use Crypt::RSA, because it has so many prereqs. Switch completely to Math::Pari? Worthwhile? Again, don't want existing SSH1 users to have to switch. Use non-blocking connect, like IO::Socket, to implement a connect Timeout. A proper scp client. Port forwarding.

Neil Watson

Replies are listed 'Best First'.
Re^2: Net::SSH::Perl ConnectTimeout (ssh -o option)
by codejerk (Initiate) on Aug 10, 2006 at 14:26 UTC
    very true. Because this module is unfinished, has anyone managed to use a workaround or modification to (at least temporarily... I'm sure btrott will get back to this module soon) implement a connect timeout?
    to summarize:
    • Net::SSH::Perl is unfinished.
    • Net::SSH::Perl does not yet have an implementation of the SSH ConnectTimeout option.
    • I am searching for a quick, temporary solution to this "feature hole"

    If anyone can assist, I will greatly appreciate the input :)
      This is a very late reply, but this has still not been implemented. I added the following to, right after the socket creation to give me a send/receive timeout of 10 seconds:

      setsockopt($sock, SOL_SOCKET, SO_SNDTIMEO, pack('LL', 10, 0) ) or die $!;
      setsockopt($sock, SOL_SOCKET, SO_RCVTIMEO, pack('LL', 10, 0) ) or die $!;

      Hope that helps.
        This work-around almost solved my problem -- but my time_t was a 64-bit integer. I believe that pack("L!L!",...) is more portable in this case.
        Well this workaround is for timeout while creating SSH object or the timeout is applicable while executing a SSH command using that object. Will it die if there is no response from the command.
      Hi folks, I would like to know if there is a way to get time taken for each step in debug mode to be displayed to find out which step is taking the longer time. Net::SSH::Perl Version 1.35, protocol version 2.0, running in debug mode I have the following timeout issue at times and would like to get UNIX time displayed besides the sourceserver like following for each debug line. Thanks.
      sourceserver unixtime: Reading configuration data /usr/local/apps/.ssh +/config sourceserver unixtime: Reading configuration data /etc/ssh_config sourceserver unixtime: Connecting to targetserver, port 22. sourceserver etc: Remote protocol version 2.0, remote software version + OpenSSH_4.3 sourceserver: Net::SSH::Perl Version 1.35, protocol version 2.0. sourceserver: No compat match: OpenSSH_4.3. sourceserver: Connection established. sourceserver: Sent key-exchange init (KEXINIT), wait response. sourceserver: Algorithms, c->s: 3des-cbc hmac-sha1 none sourceserver: Algorithms, s->c: 3des-cbc hmac-sha1 none sourceserver: Entering Diffie-Hellman Group 1 key exchange. sourceserver: Sent DH public key, waiting for reply. sourceserver: Received host key, type 'ssh-dss'. sourceserver: Host 'targetserver' is known and matches the host key. sourceserver: Computing shared secret key. sourceserver: Verifying server signature. sourceserver: Waiting for NEWKEYS message. sourceserver: Send NEWKEYS. sourceserver: Enabling encryption/MAC/compression. sourceserver: Sending request for user-authentication service. sourceserver: Service accepted: ssh-userauth. sourceserver: Trying empty user-authentication request. sourceserver: Authentication methods that can continue: publickey,gssa +pi-w ith-mic,password,keyboard-interactive. sourceserver: Next method to try is publickey. sourceserver: Next method to try is password. sourceserver: Trying password authentication. Taking too long to complete. Timed out after 60 seconds.
        The easiest solution would probably be to just patch or to redefine the module debug function.

        Another, less intrusive, option is to tie STDERR to an object that prepends the current time to every printed line.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://566623]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2017-01-19 03:21 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (167 votes). Check out past polls.