Windows Net::SSH::Win32Perl挂起

Windows Net::SSH::Win32Perl挂起,windows,perl,ssh,Windows,Perl,Ssh,嗨,我正试图从WindowsXP机器上在unix机器上做一个简单的ls。它挂起并且也不退出。可能是什么问题 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(

嗨,我正试图从WindowsXP机器上在unix机器上做一个简单的ls。它挂起并且也不退出。可能是什么问题

 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

我最近也遇到了同样的问题。下面是我如何让它为我工作的

  • 如果未设置$ENV{HOME}环境变量,请确保正在设置该变量。SSH将在其中查找配置项
  • 在Net/SSH/Perl.pm中,注释掉第49行和第50行,并用
    my$proto_class=$SSH->protocol_class($proto)替换它们

  • 您使用的是什么版本的perl?指示包不能与任何最新版本一起使用。。。我建议从winnipegThanks Andrew那里获取Net::SSH2,使用Net::SSH2实现。谢谢你的帮助乔,谢谢你的帮助。我不喜欢做上述操作,因为我必须在每个安装上实现相同的操作。我使用Net::SSH2实现了这一功能