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

So i've got a script using Net::SFTP::Foreign that is working on Cygwin and Solaris (with 1.53) but is not working on AIX (tried 1.53 and 1.54_01).
It does not seem to work properly when attempting to use password authentication. I've installed the latest Expect and IO::TTY.
The script is as below:
my $sftp = Net::SFTP::Foreign->new(host => 'myserver', user=> 'testuse +r', password => 'password'); $sftp->error() and die "Unable to connect to SFTP host - Error: " . $ +sftp->error();

Output (with 1.54_01) as follows:
Unable to connect to SFTP host - Error: Password interchange did not +complete: -1 at ./module_test.pl line 56.

I know the password to be correct as i can manually log into the sftp server with the same credentials.
Full output with more=>-v is as below:
OpenSSH_4.7p1, OpenSSL 0.9.8f 11 Oct 2007 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Failed dlopen: /usr/krb5/lib/libkrb5.a(libkrb5.a.so): Could no +t load module /usr/krb5/lib/libkrb5.a(libkrb5.a.so). System error: No such file or directory debug1: Error loading Kerberos, disabling Kerberos auth. debug1: Connecting to myserver [w.x.y.z] port 22. debug1: Connection established. debug1: identity file /home/myuser/.ssh/identity type -1 debug1: identity file /home/myuser/.ssh/id_rsa type -1 debug1: identity file /home/myuser/.ssh/id_dsa type -1 debug1: Remote protocol version 2.0, remote software version WeOnlyDo +2.1.0 debug1: no match: WeOnlyDo 2.1.0 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_4.7 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 none debug1: kex: client->server aes128-cbc hmac-md5 none debug1: sending SSH2_MSG_KEXDH_INIT debug1: expecting SSH2_MSG_KEXDH_REPLY debug1: Host 'myserver' is known and matches the RSA host key. debug1: Found key in /home/myuser/.ssh/known_hosts:5 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: password,publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/myuser/.ssh/identity debug1: Trying private key: /home/myuser/.ssh/id_rsa debug1: Trying private key: /home/myuser/.ssh/id_dsa debug1: Next authentication method: password debug1: Authentications that can continue: password,publickey debug1: No more authentication methods to try. Permission denied (password,publickey). Unable to connect to SFTP host - Error: Password interchange did not +complete: -1 at ./module_test.pl line 56.


I don't know if this points anyone in the right direction but the error i was seeing with 1.53 was different it was -
Unable to connect to SFTP host: myserver. Error: Password not requeste +d as expected: -1 at pn4_deploy_common.pl line 210. Permission denied (password,publickey).

Any help would be MUCH appreciated

Replies are listed 'Best First'.
Re: Net::SFTP::Foreign not workign properly on AIX
by salva (Canon) on Jul 29, 2009 at 08:05 UTC
    It seems that the server doesn't like the password. Are you completely sure you are using the right one?

    In any case, can you run your script under strace, or its AIX equivalent, with the required options to log the full I/O and send the output to me by email (BTW, I am the module author).

    If you could grant me shell access to an AIX box it would also greatly help.

    I don't know if this points anyone in the right direction but the error i was seeing with 1.53 was different...
    1.53 was broken, it has already been removed from CPAN

    update: Note that the strace output will contain the password and I will be able to see it!

      Email sent to salva@cpan.org - thanks!
Re: Net::SFTP::Foreign not workign properly on AIX
by Khen1950fx (Canon) on Jul 29, 2009 at 02:18 UTC
    I tried it with "and croak" instead of "and die".

    #!/usr/local/bin/perl use strict; use warnings; use Carp; use Net::SFTP::Foreign; use constant HOST => 'localhost'; my $sftp = Net::SFTP::Foreign->new(HOST, more => '-v'); $sftp->error and croak "Unable to connect: " . $sftp->error;
    Update: Fixed typos