Net::SSH::Perl Help

Discussion in 'Perl' started by blob, Sep 5, 2003.

  1. blob

    blob Guest

    Hi all,

    Below is my script that will be used to connect to a remote host and
    change my password automatically:

    ===========================================
    #!/usr/bin/perl


    use strict();
    use Net::SSH::perl;


    $user="jaws";
    $pass="password";
    $host="xxx.xxx.xxx.xxx";
    $old_password="password";
    $new_password="newpass";


    my $ssh = Net::SSH::perl->new($host,debug=>1,use_pty=>1);
    $ssh->login($user, $pass);


    $ssh->register_handler("stderr", sub {
    my($channel, $buffer) = @_;
    my $str = $buffer->bytes;


    if ($str eq "Enter login password: ") {
    $channel->send_data($old_password);
    }


    elsif ($str eq "New password: ") {
    $channel->send_data($new_password);
    }

    elsif ($str eq "Re-enter new password: ") {
    $channel->send_data($new_password);
    }
    });
    $ssh->cmd('passwd');
    ==========================================

    After running the program, my password didnt changed I was still able to
    connect using the old password.

    Does anybody has an idea what's missing or wrong with my script?

    Thanks.

    Jaws
     
    blob, Sep 5, 2003
    #1
    1. Advertisements

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. loial
    Replies:
    0
    Views:
    635
    loial
    Feb 3, 2009
  2. Tench Johnson
    Replies:
    1
    Views:
    513
    Biff Tannen
    Apr 23, 2010
  3. salamond

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    496
    salamond
    Feb 17, 2011
  4. Andy
    Replies:
    6
    Views:
    279
  5. roygbaba

    help with sudo and net::ssh:perl

    roygbaba, Sep 5, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    521
    roygbaba
    Sep 5, 2006
  6. Stephane Charette
    Replies:
    3
    Views:
    334
  7. vendion

    Net::SSH::Perl Help

    vendion, Mar 26, 2009, in forum: Perl Misc
    Replies:
    17
    Views:
    269
    J. Gleixner
    Mar 31, 2009
  8. Replies:
    0
    Views:
    467
Loading...