#-- set up a new connection $ssh = Net::SSH::Perl->new("$host", debug => 1, use_pty => 1, interactive => 1, identity_files => [], protocol=>'2,1'); #-- authenticate #print "Loggin onto $host...\n" ; # Authenticate using login/password: $ssh->login($user, "$pass"); my($stdout1, $stderr1, $exit1) = $ssh->cmd("su -", ["$mypassword\r\n"]); print "error= $stderr1\n" ;