Hm... further investigations make me think there's a bug in Net::SSH::Perl or Net::SFTP.
try adding this to your code:
my %args = (
user => 'user',
password => 'password',
ssh_args => [
debug => 1,
options => [
"PreferredAuthentications 'keyboard-interactive,password,h
+ostbased,publickey'",
]
],
);
and then:
eval { $sftp = Net::SFTP->new($host, %args) };
die "Connection failed: $!\n" if $!;
die "No SFTP object\n" unless $sftp;
my output goes like:
wolf: Reading configuration data /home/insaniac/.ssh/config
wolf: Reading configuration data /etc/ssh_config
wolf: Connecting to bear, port 22.
wolf: Remote protocol version 2.0, remote software version OpenSSH_4.2
+p1 Debian-4
wolf: Net::SSH::Perl Version 1.28, protocol version 2.0.
wolf: No compat match: OpenSSH_4.2p1 Debian-4.
wolf: Connection established.
wolf: Sent key-exchange init (KEXINIT), wait response.
wolf: Algorithms, c->s: 3des-cbc hmac-sha1 none
wolf: Algorithms, s->c: 3des-cbc hmac-sha1 none
wolf: Entering Diffie-Hellman Group 1 key exchange.
wolf: Sent DH public key, waiting for reply.
wolf: Received host key, type 'ssh-dss'.
wolf: Host 'bear' is known and matches the host key.
wolf: Computing shared secret key.
wolf: Verifying server signature.
wolf: Waiting for NEWKEYS message.
wolf: Enabling incoming encryption/MAC/compression.
wolf: Send NEWKEYS, enable outgoing encryption/MAC/compression.
wolf: Sending request for user-authentication service.
wolf: Service accepted: ssh-userauth.
wolf: Trying empty user-authentication request.
wolf: Authentication methods that can continue: publickey,keyboard-int
+eractive.
wolf: Next method to try is publickey.
wolf: Trying pubkey authentication with key file '/home/insaniac/.ssh/
+id_dsa'
wolf: Authentication methods that can continue: publickey,keyboard-int
+eractive.
wolf: Next method to try is publickey.
Connection failed: No such file or directory
So when I try authenticating with an ssh-key, all works out perfectly. When I try to supply a username and a password, they seem to be ignored.. maybe we need to supply a specific value to ssh_args ?
Per default, Net::SFTP uses the username that's executing the script as SSH username...
I'll keep you informed if I find a solution...
Cheers, Johnny
to ask a question is a moment of shame
to remain ignorant is a lifelong shame