2012-03-26 87 views
-1

嗨我想在windows xp機器上的unix框上做一個簡單的ls。它掛起,也不會退出。可能是什麼問題Net :: SSH :: Win32Perl掛起

use Net::SSH::W32Perl; 
use diagnostics; 

    my $host = 'host'; 
    my $ssh = new Net::SSH::W32Perl($host, debug => 1); 
    $ssh->login('username', 'password'); 
    my $cmd = "ls"; 
    my($stdout, $stderr, $exit) = $ssh->cmd($cmd); 
    print "$stdout"; 
    exit; 
下面

是輸出,發現它已經能夠使用密碼驗證,但它不是能夠給輸出登錄。這是爲什麼?

> C:\>perl winssh.pl 
>  WXVM0026: Reading configuration data c:\/.ssh/config 
>  WXVM0026: Reading configuration data /etc/ssh_config 
>  WXVM0026: Connecting to hp-test, port 22. 
>  WXVM0026: Socket created, turning on blocking... 
>  WXVM0026: Remote protocol version 2.0, remote software version OpenSSH_4.3p2-hpn 
>  WXVM0026: Net::SSH::Perl Version 1.34, protocol version 2.0. 
>  WXVM0026: No compat match: OpenSSH_4.3p2-hpn. 
>  WXVM0026: Connection established. 
>  WXVM0026: Sent key-exchange init (KEXINIT), wait response. 
>  WXVM0026: Algorithms, c->s: 3des-cbc hmac-sha1 none 
>  WXVM0026: Algorithms, s->c: 3des-cbc hmac-sha1 none 
>  WXVM0026: Entering Diffie-Hellman Group 1 key exchange. 
>  WXVM0026: Sent DH public key, waiting for reply. 
>  WXVM0026: Received host key, type 'ssh-dss'. 
>  WXVM0026: Host 'hp-test' is known and matches the host key. 
>  WXVM0026: Computing shared secret key. 
>  WXVM0026: Verifying server signature. 
>  WXVM0026: Waiting for NEWKEYS message. 
>  WXVM0026: Send NEWKEYS. 
>  WXVM0026: Enabling encryption/MAC/compression. 
>  WXVM0026: Sending request for user-authentication service. 
>  WXVM0026: Service accepted: ssh-userauth. 
>  WXVM0026: Trying empty user-authentication request. 
>  WXVM0026: Authentication methods that can continue: publickey,password,keyboard-interactive. 
>  WXVM0026: Next method to try is publickey. 
>  WXVM0026: Next method to try is password. 
>  WXVM0026: Trying password authentication. 
>  WXVM0026: Login completed, opening dummy shell channel. 
>  WXVM0026: channel 0: new [client-session] 
>  WXVM0026: Requesting channel_open for channel 0. 
>  WXVM0026: channel 0: open confirm rwindow 0 rmax 32768 
>  WXVM0026: Got channel open confirmation, requesting shell. 
>  WXVM0026: Requesting service shell on channel 0. 
>  WXVM0026: channel 1: new [client-session] 
>  WXVM0026: Requesting channel_open for channel 1. 
>  WXVM0026: Entering interactive session. 
>  WXVM0026: Sending command: ls 
>  WXVM0026: Sending command: ls 
>  WXVM0026: Requesting service exec on channel 1. 
>  WXVM0026: channel 1: send eof 
>  WXVM0026: channel 1: open confirm rwindow 2097151 rmax 32768 
>  WXVM0026: input_channel_request: rtype exit-status reply 0 
>  WXVM0026: channel 1: rcvd eof 
>  WXVM0026: channel 1: output open -> drain 
>  WXVM0026: channel 1: rcvd close 
+0

您正在使用什麼版本的Perl替代它們? http://code.activestate.com/ppm/Net-SSH-W32Perl/表示該軟件包不能與任何最新版本一起工作...我建議從winnipeg獲得Net :: SSH2 – 2012-03-26 13:32:36

+0

謝謝Andrew,明白了吧使用Net :: SSH2。感謝您的幫助 – Zack 2012-03-28 05:59:28

回答

0

我最近遇到了同樣的問題。 I found a solution in PerlMonks以下是我如何爲我工作。

  1. 確保您設置你的$ ENV {HOME}環境變量,如果它未設置。 Net :: SSH將在那裏尋找配置項目。
  2. 在net/SSH/Perl.pm,註釋掉線49和50,並與my $proto_class = $ssh->protocol_class($proto);
+0

Joel,感謝您的幫助。我不喜歡這樣做,因爲我必須在每個安裝上實現相同的功能。我得到了使用Net :: SSH2的東西 – Zack 2012-03-28 06:00:30