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

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:
If anyone can assist, I will greatly appreciate the input :)
  • Comment on Re^2: Net::SSH::Perl ConnectTimeout (ssh -o option)

Replies are listed 'Best First'.
Re^3: Net::SSH::Perl ConnectTimeout (ssh -o option)
by Anonymous Monk on Sep 21, 2007 at 18:49 UTC
    This is a very late reply, but this has still not been implemented. I added the following to Perl.pm, 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.
    --mf
      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.
      Thanks
Re^3: Net::SSH::Perl ConnectTimeout (ssh -o option)
by Anonymous Monk on Jan 21, 2015 at 00:57 UTC
    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.

        Thanks salva for the suggestions. I added the time() in the debug line as I not sure to tie time to STDERR. Suggestion welcome. As far as the timeout is concerned, issue is from
        sourceserver: Trying password authentication. to sourceserver: Login completed, opening dummy shell channel. (please no +te this obtained from a successful login attempt, without timeout) Taking too long to complete. Timed out after 60 seconds.
        I'm using following code to logon to target server:
        $ssh = Net::SSH::Perl->new($server, debug => 15, options=> [ "UserKnownHostsFile /usr/local/apps/.ssh/known_hosts"]);
        Is there other option I could use to debug this further? Thanks.