LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How is it possible to login as root with Perl script and used telnet.pm (https://www.linuxquestions.org/questions/linux-software-2/how-is-it-possible-to-login-as-root-with-perl-script-and-used-telnet-pm-346825/)

manu0573 07-26-2005 01:59 AM

How is it possible to login as root with Perl script and used telnet.pm
 
Hi,

I write a perl script under UNIX/LINUX.
The aim of this script is to open a telnet session as ROOT.
To do this, I use the library telnet.pm under perl.
Following is my source code :

#!/usr/bin/perl

use Net::Telnet;
my $fh1,$fh2,$fh3;
$telnet = new Net::Telnet ( Timeout=>10, Errmode=>'die', Prompt=>'/\$ $/i');
$fh1 = $telnet->option_log("optionlog.txt");
$fh2 = $telnet->input_log("inputlog.txt");
$fh3 = $telnet->output_log("outputlog.txt");
$telnet->open('$HOST_IP');
$telnet->login('root', '');
print $telnet->cmd('ls');

When I run this script, I have the following message :

timed-out waiting for password prompt at MyScript.pl

But when I want to open a telnet session and login as root any password is needed !!!!

I don't understand what is happened ?

Can someone tell me how it is possible do this with telnet.pm under perl script ?

Best regards, @+, Manu

poochdog 07-27-2005 05:22 PM

I don't think you can login as root under telnet. You can using ssh as that is more secure but with telnet there is little in the way of security.


All times are GMT -5. The time now is 07:39 PM.