SSH: $ssh->cmd("passwd") does not work properly
From: Quackie (minh_quoc_at_yahoo.com)
Date: 05/06/03
- Previous message: Neil Pike: "Re: SSH Batch tranfser Help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: 5 May 2003 17:35:52 -0700
I devenlop a Perl script that automately log in to remote server using
SSH2 and execute series of commands.
My Perl client runs on Windows 2000 using Net::SSH:W32Perl package.
My SSH server is OpenSSH3.6.1 runs on Solaris 8.
Everything works fine. I can login to remote server with password
authentication, public key authentication ... and runs few commands
such as "ls", "whoami" ... However, for the command that require
interaction from the user input such as "su" or "passwd", I have the
problem.
This is part of my script
use strict;
use Net::SSH::W32Perl;
my $ssh = Net::SSH::W32Perl->new($host, debug => 1);
$ssh->login("username", "password");
$ssh->register_handler("stderr", sub {
my($channel, $buffer) = @_;
my $str = $buffer->bytes;
# debug
print "str received is ", $str;
if ($str eq "Enter login password: ") {
$channel->send_data($old_password);
}
elsif ($str eq "New password: ") {
$channel->send_data($new_password);
}
elsif ($str eq "Retype new password: ") {
$channel->send_data($new_password);
}
});
## After registering the handler, we run the command.
$ssh->cmd('passwd');
After executing this script, the str received is not one of those
expected prompts (New password , ....), but I got the message "passwd:
Permission denied" for the str.
Tried it with "su" command instead of "passwd" and I got the message
"su:Sorry". It seems to me that the server does not stop at the
command prompt and send it back, but instead go all the way to the
user prompt and send back the error message of that command.
Anyone here has any clue about this?
Thanks in advance
- Previous message: Neil Pike: "Re: SSH Batch tranfser Help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|