Re: [Ssh-sftp-perl-users] Problem With Net::SSH:Perl
Brought to you by:
dbrobins
From: Ian D. <Ian...@bd...> - 2009-06-17 09:33:20
|
Hi You need to include all of your code when you report problems, or at least a 'cut-down' fully working program that demonstrates the problem. If you had done so in this case we could have seen that you had not included the following in your perl program. use strict; use warnings; I can tell that you have not done so since you your interactive=>FALSE would have given a warning like Bareword "FALSE" not allowed while "strict subs" in use at ssh.pl line 10. This is doing the exact opposite of what you are expecting. Since you have not turned on strict and warnings pragmas then perl is converting the FALSE into a scalar, which is then being evaluated as a true value so requesting the prompt! If you read the documentation you will see that it defaults to false (perl false not FALSE) so it should not request the password. A complete example (which I have tested) is as follows. #!/usr/bin/perl use Net::SSH::Perl; use strict; use warnings; my $host = 'your.domain.com'; my $user = 'root'; my $passwd = 'secret'; my $scon = Net::SSH::Perl->new ($host); $scon->login($user, $passwd); print "looking around...\n"; my ($output, $errors, $exit) = $scon->cmd("ls -l"); print "output=[$output] errors=[$errors] exit=[$exit]\n"; If this still does not work then you have to double check that you can ssh onto the host using the credentials you are putting into your program. Regards Ian ________________________________ From: cheerla sreehari [mailto:ch....@gm...] Sent: 17 June 2009 06:22 To: ssh...@li... Subject: [Ssh-sftp-perl-users] Problem With Net::SSH:Perl Hi , I am using the following code to connect to the remote host . use Net::SSH::Perl ; $scon = Net::SSH::Perl->new ("$host",interactive=>FALSE); $scon->login("root","$passwd"); print "looking around ...\n"; ($output,$errors,$exit) = $scon->cmd("ls -l"); print $output; When I execute this code , it is prompting for the password . I want to ssh without prompting for the password . Please suggest me how I can modify the above code to ssh a client without prompting for the password . Thanks in Advance . Regards, SreeHari CH This email is confidential and intended solely for the use of the individual to whom it is addressed. Any views or opinions presented are solely those of the author and do not necessarily represent those of RedBee Media Metadata. If you are not the intended recipient, be advised that you have received this email in error and that any use, dissemination, forwarding, printing, or copying of this email is strictly prohibited. If you have received this email in error please notify the sender. Red Bee Media Metadata is a trading name of Broadcasting Dataservices Limited. Registered in England and Wales No.: 2554733. Registered Office: 201 Wood Lane, London W12 7TP, UK. Broadcasting Dataservices Limited is a wholly owned subsidiary of Red Bee Media Limited. |