#!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; my $ssh = Net::SSH::Expect-> new ( host => "10.10.10.10", password => "abcdefg", user => "root", raw_pty => 1, timeout => 3 ); my $login_output=$ssh->login(); if ( $login_output =~ /Last/ ) { print "The login was successful \n"; print "Let's change the password of root on remote server now \n"; $ssh->send("passwd"); $ssh->waitfor('password:\s',10) or die "Where is the password prompt??"; $ssh->send("new_pass"); $ssh->waitfor('password:\s*\z',10) or die "Where is the password prompt??"; $ssh->send("new_passwd"); } else { die "Log in attempt failed with $! \n"; } #### $ssh->send("find /"); #### $ssh->exec("find /");