Thread: [Ssh-sftp-perl-users] Problem With Net::SSH:Perl
Brought to you by:
dbrobins
From: cheerla s. <ch....@gm...> - 2009-06-17 05:21:33
|
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 |
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. |
From: cheerla s. <ch....@gm...> - 2009-06-17 10:06:08
|
Hi , I exactly used the code given by you by just changing the $host and $passwd . When I execute that it is still prompting for the password . So we need to configure SSH for not prompting the password ? Thanks for the help . Regards, SreeHari CH On Wed, Jun 17, 2009 at 5:32 AM, Ian Docherty <Ian...@bd...> wrote: > 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. > |
From: Ian D. <Ian...@bd...> - 2009-06-17 10:43:54
|
Hi Two things. First double (triple) check that the username, password combination works from the command line. Second add the debug=>1 option to the new and post the debug output you get when you try to make a connection. my $scon = Net::SSH::Perl->new ($host, debug=>1); Regards Ian ________________________________ From: cheerla sreehari [mailto:ch....@gm...] Sent: 17 June 2009 11:06 To: Ian Docherty Cc: ssh...@li... Subject: Re: [Ssh-sftp-perl-users] Problem With Net::SSH:Perl Hi , I exactly used the code given by you by just changing the $host and $passwd . When I execute that it is still prompting for the password . So we need to configure SSH for not prompting the password ? Thanks for the help . Regards, SreeHari CH On Wed, Jun 17, 2009 at 5:32 AM, Ian Docherty <Ian...@bd...> wrote: 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. 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. |
From: <<<<Amar>>>> <ama...@gm...> - 2009-06-17 13:22:33
|
Hello You need to create public/private keys via SSH-keygen You can refer for any documentation of how to set up password less SSH login. ~Amardeep. On Wed, Jun 17, 2009 at 3:36 PM, cheerla sreehari <ch....@gm...>wrote: > Hi , > > I exactly used the code given by you by just changing the $host and $passwd > . When I execute that it is still prompting for the password . > > So we need to configure SSH for not prompting the password ? > > Thanks for the help . > > Regards, > SreeHari CH > > > On Wed, Jun 17, 2009 at 5:32 AM, Ian Docherty <Ian...@bd...> wrote: > >> 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. >> > > > > ------------------------------------------------------------------------------ > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables unlimited > royalty-free distribution of the report engine for externally facing > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > |
From: Ian D. <Ian...@bd...> - 2009-06-17 14:05:51
|
Amardeep I responded earlier that creating password-less public/private keys was an option, but the code I gave to login using a password is what was asked for (and frankly easier to set up for the uninitiated than using SSH-keygen). I agree that passwordless SSH login is a much better solution if only because it does not require passwords to be 'hard-coded' into scripts or config files. By the way SreeHari I would seriously recommend *not* using the root account to try out this script. You should set up a separate user account with limited access if you are going to be doing this. Regards Ian ________________________________ From: <<<<Amar>>>> [mailto:ama...@gm...] Sent: 17 June 2009 13:17 To: cheerla sreehari Cc: Ian Docherty; ssh...@li... Subject: Re: [Ssh-sftp-perl-users] Problem With Net::SSH:Perl Hello You need to create public/private keys via SSH-keygen You can refer for any documentation of how to set up password less SSH login. ~Amardeep. On Wed, Jun 17, 2009 at 3:36 PM, cheerla sreehari <ch....@gm...> wrote: Hi , I exactly used the code given by you by just changing the $host and $passwd . When I execute that it is still prompting for the password . So we need to configure SSH for not prompting the password ? Thanks for the help . Regards, SreeHari CH On Wed, Jun 17, 2009 at 5:32 AM, Ian Docherty <Ian...@bd...> wrote: 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. ------------------------------------------------------------------------ ------ Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing server and web deployment. http://p.sf.net/sfu/businessobjects _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users 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. |