0

I'm using Net::SFTP to transfer files. However, whenever I try to create a new object like so:

my $sftp = Net::SFTP->new('ip', user=>'user', password=>'pass');

It just hangs and does nothing. Does anyone know why this is? Am I doing something wrong? Thanks!

Update

Here is the debug output:

dev1.com: Reading configuration data /home/user/.ssh/config
dev1.com: Reading configuration data /etc/ssh_config
dev1.com: Connecting to 50.56.91.91, port 22.
dev1.com: Remote protocol version 2.0, remote software version OpenSSH_4.3
dev1.com: Net::SSH::Perl Version 1.34, protocol version 2.0.
dev1.com: No compat match: OpenSSH_4.3.
dev1.com: Connection established.
dev1.com: Sent key-exchange init (KEXINIT), wait response.
dev1.com: Algorithms, c->s: 3des-cbc hmac-sha1 none
dev1.com: Algorithms, s->c: 3des-cbc hmac-sha1 none
dev1.com: Entering Diffie-Hellman Group 1 key exchange.
dev1.com: Sent DH public key, waiting for reply. 
dev1.com: Received host key, type 'ssh-dss'.
dev1.com: Host 'ip_here' is known and matches the host key.
dev1.com: Computing shared secret key.
dev1.com: Verifying server signature.
dev1.com: Waiting for NEWKEYS message.
dev1.com: Send NEWKEYS.
dev1.com: Enabling encryption/MAC/compression.
dev1.com: Sending request for user-authentication service.
dev1.com: Service accepted: ssh-userauth. 
dev1.com: Trying empty user-authentication request.
dev1.com: Authentication methods that can continue: publickey,gssapi-with mic,password.
dev1.com: Next method to try is publickey.
dev1.com: Trying pubkey authentication with key file '/home/user/.ssh/id_rsa2'
Borodin
  • 126,100
  • 9
  • 70
  • 144
srchulo
  • 5,143
  • 4
  • 43
  • 72
  • I imagine it's trying to connect and the request is falling on deaf ears. Perhaps a firewall issue? – ikegami Feb 25 '13 at 00:19
  • @ikegami, but the thing is that I can use ssh from the command line. So I would think that it's probably not a firewall issue. – srchulo Feb 25 '13 at 00:22
  • It seems to be ignoring your password and using a public key instead. Do you provide a password when you connect from the command line? Is the stuff in `/home/user/.ssh` correct? – Borodin Feb 25 '13 at 01:14
  • When I connect from the command line I do not use a password-- it just uses my key. And I believe that the stuff in `/home/user/.ssh` is correct, because it works when I ssh from the command line. They key that it is trying to use in the debug output is the same key I use to connect from the command line. – srchulo Feb 25 '13 at 01:50
  • 1
    the Net::SFTP/Net::SSH::Perl modules are not maintained any more and have lots of bugs. Try using [Net::SFTP::Foreign](https://metacpan.org/module/Net::SFTP::Foreign) instead. – salva Feb 27 '13 at 10:07

2 Answers2

2

In addition to the user and password options, set debug => 1. You will get some diagnostic output that may tell you what the problem is.

Borodin
  • 126,100
  • 9
  • 70
  • 144
2

Search if your connection data is correct. Use a simple code like that showed in Net::SFTP::Foreign .

Mihai8
  • 3,113
  • 1
  • 21
  • 31