Net::SSH::Perl - Broken Pipe

Discussion in 'Perl Misc' started by azzi.george@gmail.com, Feb 27, 2007.

  1. Guest

    Dear Perl Programmers,

    Good evening. Am trying to use Net::SSH::perl to do a simple ls -l
    command on a remote system. However, it keeps giving a Broken Pipe
    error. Below is the script, along with the error.

    Also, it is taking unusually long to just login. Confirmed there is a
    connection using ps -ef on the remote machine. Any help given would be
    greatly appreciated. Note that this is running on solaris 10 (not
    sure if that makes a difference). Thank you in advance for your help.


    Pierre


    Perl Script:
    -------------------------------------
    #!/usr/bin/perl


    use warnings;
    use strict;
    use Net::SSH::perl;


    my $user;
    my $pass;


    my $cmd = "ls -lrt /tmp/*.txt";
    my $pwd = "ssh_info.txt";
    my $host = "x.x.x.x";


    open ('LOGIN', "$pwd") || die "$!\n";
    while (<LOGIN>) {
    ($user, $pass) = split /:/, $_;


    }


    close 'LOGIN' || die "LOGIN FH: $! \n";

    my $ssh = Net::SSH::perl->new($host, debug =>1, protocol =>'2,1');
    print "$host\n";
    print "Command that will be run before logging in: $cmd\n";


    $ssh->config->set('interactive', 1)
    unless defined $ssh->config->get('interactive');


    $ssh->login($user,$pass);


    print "Command that is about to be run: $cmd\n";
    my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);
    print "$tdout\n";


    Error Received
    -------------------------------------------------------------------
    Reading configuration data /var/home/collect/.ssh/config
    Reading configuration data /etc/ssh_config
    Connecting to x.x.x.x, port 22.
    Remote version string: SSH-2.0-OpenSSH_4.3


    Remote protocol version 2.0, remote software version OpenSSH_4.3
    Net::SSH::perl Version 1.30, protocol version 2.0.
    No compat match: OpenSSH_4.3.
    Connection established.
    x.x.x.x
    Command that will be run before logging in: ls -lrt /tmp/*.txt
    Sent key-exchange init (KEXINIT), wait response.
    Algorithms, c->s: 3des-cbc hmac-sha1 none
    Algorithms, s->c: 3des-cbc hmac-sha1 none
    Entering Diffie-Hellman Group 1 key exchange.
    Sent DH public key, waiting for reply.
    Received host key, type 'ssh-dss'.
    Host 'x.x.x.x' is known and matches the host key.
    Computing shared secret key.
    Verifying server signature.
    Waiting for NEWKEYS message.
    Enabling incoming encryption/MAC/compression.
    Send NEWKEYS, enable outgoing encryption/MAC/compression.
    Sending request for user-authentication service.
    Broken Pipe
     
    , Feb 27, 2007
    #1
    1. Advertising

  2. Guest

    Install Math::BigInt::GMP to speed up the time it takes to login.

    Not sure why you are getting a broken pipe. Can you ssh from the
    command line of your dev box to the remote server?

    On Feb 26, 8:02 pm, wrote:
    > Dear Perl Programmers,
    >
    > Good evening. Am trying to use Net::SSH::perl to do a simple ls -l
    > command on a remote system. However, it keeps giving a Broken Pipe
    > error. Below is the script, along with the error.
    >
    > Also, it is taking unusually long to just login. Confirmed there is a
    > connection using ps -ef on the remote machine. Any help given would be
    > greatly appreciated. Note that this is running on solaris 10 (not
    > sure if that makes a difference). Thank you in advance for your help.
    >
    > Pierre
    >
    > Perl Script:
    > -------------------------------------
    > #!/usr/bin/perl
    >
    > use warnings;
    > use strict;
    > use Net::SSH::perl;
    >
    > my $user;
    > my $pass;
    >
    > my $cmd = "ls -lrt /tmp/*.txt";
    > my $pwd = "ssh_info.txt";
    > my $host = "x.x.x.x";
    >
    > open ('LOGIN', "$pwd") || die "$!\n";
    > while (<LOGIN>) {
    > ($user, $pass) = split /:/, $_;
    >
    > }
    >
    > close 'LOGIN' || die "LOGIN FH: $! \n";
    >
    > my $ssh = Net::SSH::perl->new($host, debug =>1, protocol =>'2,1');
    > print "$host\n";
    > print "Command that will be run before logging in: $cmd\n";
    >
    > $ssh->config->set('interactive', 1)
    > unless defined $ssh->config->get('interactive');
    >
    > $ssh->login($user,$pass);
    >
    > print "Command that is about to be run: $cmd\n";
    > my ($stdout, $stderr, $exit) = $ssh->cmd($cmd);
    > print "$tdout\n";
    >
    > Error Received
    > -------------------------------------------------------------------
    > Reading configuration data /var/home/collect/.ssh/config
    > Reading configuration data /etc/ssh_config
    > Connecting to x.x.x.x, port 22.
    > Remote version string: SSH-2.0-OpenSSH_4.3
    >
    > Remote protocol version 2.0, remote software version OpenSSH_4.3
    > Net::SSH::perl Version 1.30, protocol version 2.0.
    > No compat match: OpenSSH_4.3.
    > Connection established.
    > x.x.x.x
    > Command that will be run before logging in: ls -lrt /tmp/*.txt
    > Sent key-exchange init (KEXINIT), wait response.
    > Algorithms, c->s: 3des-cbc hmac-sha1 none
    > Algorithms, s->c: 3des-cbc hmac-sha1 none
    > Entering Diffie-Hellman Group 1 key exchange.
    > Sent DH public key, waiting for reply.
    > Received host key, type 'ssh-dss'.
    > Host 'x.x.x.x' is known and matches the host key.
    > Computing shared secret key.
    > Verifying server signature.
    > Waiting for NEWKEYS message.
    > Enabling incoming encryption/MAC/compression.
    > Send NEWKEYS, enable outgoing encryption/MAC/compression.
    > Sending request for user-authentication service.
    > Broken Pipe
     
    , Mar 6, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tomas Penc
    Replies:
    3
    Views:
    36,050
  2. Tench Johnson
    Replies:
    1
    Views:
    311
    Biff Tannen
    Apr 23, 2010
  3. Pim Snel

    use pipe with net/ssh

    Pim Snel, Feb 16, 2011, in forum: Ruby
    Replies:
    0
    Views:
    108
    Pim Snel
    Feb 16, 2011
  4. salamond

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    265
    salamond
    Feb 17, 2011
  5. Replies:
    0
    Views:
    122
Loading...

Share This Page