DougC has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I'm doing some testing of the Net::SFTP module to connect from my linux box to a solaris box.
I've written the following test code:

#!/usr/bin/perl use strict; use warnings; use Net::SFTP; # Set up the variables for the FTP. my $hostname = 'myhost'; my $sftp; our %args=( user => "myuser", password => "mypass", debug => 1 ); $sftp = Net::SFTP->new($hostname, %args); # close($sftp->{ssh}->sock()); print $sftp->status;

This does work, but takes 3 - 4 minutes to complete. I have tried sftp from the command line and this works very quickly so I'm not quite sure whats going on.

The debug info from my script is:

[test]$ ./sftp.pl appdev: Reading configuration data /home/doug/.ssh/config appdev: Reading configuration data /etc/ssh_config appdev: Connecting to rmcsap01, port 22. appdev: Remote protocol version 2.0, remote software version Sun_SSH_1 +.0 appdev: Net::SSH::Perl Version 1.28, protocol version 2.0. appdev: No compat match: Sun_SSH_1.0. appdev: Connection established. appdev: Sent key-exchange init (KEXINIT), wait response. appdev: Algorithms, c->s: 3des-cbc hmac-sha1 none **appdev: Algorithms, s->c: 3des-cbc hmac-sha1 none appdev: Entering Diffie-Hellman Group 1 key exchange. appdev: Sent DH public key, waiting for reply. appdev: Received host key, type 'ssh-dss'. appdev: Host 'rmcsap01' is known and matches the host key. **appdev: Computing shared secret key. appdev: Verifying server signature. appdev: Waiting for NEWKEYS message. appdev: Enabling incoming encryption/MAC/compression. appdev: Send NEWKEYS, enable outgoing encryption/MAC/compression. appdev: Sending request for user-authentication service. appdev: Service accepted: ssh-userauth. appdev: Trying empty user-authentication request. appdev: Authentication methods that can continue: publickey,password. appdev: Next method to try is publickey. appdev: Next method to try is password. appdev: Trying password authentication. appdev: Login completed, opening dummy shell channel. appdev: channel 0: new [client-session] appdev: Requesting channel_open for channel 0. appdev: channel 0: open confirm rwindow 0 rmax 16384 appdev: Got channel open confirmation, requesting shell. appdev: Requesting service shell on channel 0. appdev: channel 1: new [client-session] appdev: Requesting channel_open for channel 1. appdev: Sending subsystem: sftp appdev: Requesting service subsystem on channel 1. appdev: channel 1: open confirm rwindow 0 rmax 16384 appdev: sftp: Sending SSH2_FXP_INIT appdev: sftp: Remote version: 2

I've marked the lines that pause for longest with a **.
Anyone got any ideas.

many thanks,
Doug.

Replies are listed 'Best First'.
Re: Net::SFTP connection takes long time
by borisz (Canon) on Sep 19, 2005 at 10:48 UTC
      Well thats just so much better :) many thanks!

      Doug.