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

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.

Replies are listed 'Best First'.
Re^4: Net::SSH::Perl ConnectTimeout (ssh -o option)
by salva (Canon) on Jan 21, 2015 at 08:16 UTC
    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.
        I don't know. There could be some incompatibility/bug on the remote server. It announces itself as OpenSSH 4.3 so, it is quite old!

        As you seem to be on a Linux or Unix system my advice would be to use my module Net::OpenSSH. Net::SSH::Perl is mostly unmaintained nowadays and full of bugs.