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

    net/ssh in ruby. ssh.exec fails

    salamond, Feb 17, 2011, in forum: Ruby
    Replies:
    0
    Views:
    268
    salamond
    Feb 17, 2011
  5. Replies:
    0
    Views:
    126
Loading...

Share This Page