2013-02-25 65 views
0

我正在使用Net::SFTP來傳輸文件。然而,每當我嘗試創建一個像這樣的新對象時:Net :: SFTP掛起

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

它只是掛起而什麼都不做。有人知道爲什麼嗎?難道我做錯了什麼?謝謝!

更新

下面是調試輸出:

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' 
+0

我想它是試圖連接和請求失聰。也許是防火牆問題? – ikegami 2013-02-25 00:19:06

+0

@ikegami,但事情是我可以在命令行中使用ssh。所以我會認爲這可能不是防火牆問題。 – srchulo 2013-02-25 00:22:52

+0

它似乎忽略了您的密碼並改爲使用公鑰。從命令行連接時,你提供密碼嗎? '/ home/user/.ssh'中的內容是否正確? – Borodin 2013-02-25 01:14:33

回答

2

除了userpassword選項,設置debug => 1。您將得到一些診斷輸出,可以告訴您問題是什麼。

+0

感謝您的建議。我已經發布了上面的調試輸出。 – srchulo 2013-02-25 00:25:34

2

搜索您的連接數據是否正確。使用Net::SFTP::Foreign中顯示的簡單代碼。

+0

非常感謝! Net :: SFTP :: Foreign看起來不錯:) – srchulo 2013-02-28 06:40:22