ssh-sftp-perl-users Mailing List for Net::SSH and Net::SFTP - Perl modules (Page 22)
Brought to you by:
dbrobins
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(6) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(4) |
Feb
(15) |
Mar
(13) |
Apr
(8) |
May
(5) |
Jun
(21) |
Jul
(4) |
Aug
(9) |
Sep
(11) |
Oct
(14) |
Nov
(15) |
Dec
(24) |
2005 |
Jan
(10) |
Feb
(20) |
Mar
(16) |
Apr
(10) |
May
(12) |
Jun
(16) |
Jul
(18) |
Aug
(21) |
Sep
(11) |
Oct
(19) |
Nov
(16) |
Dec
(9) |
2006 |
Jan
(17) |
Feb
(32) |
Mar
(60) |
Apr
(21) |
May
(24) |
Jun
(1) |
Jul
(6) |
Aug
(18) |
Sep
(4) |
Oct
(9) |
Nov
(31) |
Dec
(10) |
2007 |
Jan
(8) |
Feb
(11) |
Mar
(3) |
Apr
(7) |
May
(4) |
Jun
(6) |
Jul
(7) |
Aug
(3) |
Sep
(2) |
Oct
(5) |
Nov
(5) |
Dec
(5) |
2008 |
Jan
(12) |
Feb
(5) |
Mar
(7) |
Apr
(4) |
May
(37) |
Jun
(9) |
Jul
(24) |
Aug
(5) |
Sep
(2) |
Oct
(7) |
Nov
(6) |
Dec
(7) |
2009 |
Jan
(18) |
Feb
(9) |
Mar
(14) |
Apr
(14) |
May
(1) |
Jun
(14) |
Jul
(4) |
Aug
(6) |
Sep
(4) |
Oct
(12) |
Nov
(4) |
Dec
|
2010 |
Jan
|
Feb
(3) |
Mar
|
Apr
(1) |
May
(4) |
Jun
|
Jul
(6) |
Aug
(6) |
Sep
|
Oct
(7) |
Nov
(2) |
Dec
(5) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(1) |
May
(8) |
Jun
(1) |
Jul
|
Aug
(2) |
Sep
|
Oct
(4) |
Nov
(9) |
Dec
(7) |
2012 |
Jan
(1) |
Feb
(19) |
Mar
(4) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
(5) |
Jul
(3) |
Aug
(1) |
Sep
|
Oct
|
Nov
(6) |
Dec
|
2014 |
Jan
(7) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Matthew J. S. <vag...@ya...> - 2006-03-30 03:15:06
|
You need to install the Net::SSH::Perl module. you can use the cpan shell to install it # cpan install Net::SSH::Perl libnet-ssh-perl is probably used by Net::SSH --- Bobby Jafari <bob...@se...> wrote: > Hi Sandy, > I have attempted the following: > #!/usr/bin/perl > use strict; > use Net::SSH::Perl; > my $user = "root"; > my $pass = "password"; > my $host = "192.168.0.173"; > my $cmd = "cat /proc/meminfo"; > my $ssh = Net::SSH::Perl->new($host); > $ssh->login($user, $pass); > my($stdout, $stderr, $exit) = $ssh->cmd($cmd); > > I get the following error, even though I have > installed libnet-ssh-perl > on my debian Linux server. > Can't locate Net/SSH/Perl.pm in @INC (@INC contains: > /etc/perl > /usr/local/lib/perl/5.8.4 > /usr/local/share/perl/5.8.4 /usr/lib/perl5 > /usr/share/perl5 /usr/lib/perl/5.8 > /usr/share/perl/5.8 > /usr/local/lib/site_perl .) at > 1023-sessions-delete500-memorySqueeze.pl > line 8. > BEGIN failed--compilation aborted at > 1023-sessions-delete500-memorySqueeze.pl line 8. > There were 2 Failures in Test Case > 1023-sessions-delete500-memorySqueeze.pl > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Bobby J. <bob...@se...> - 2006-03-30 00:29:02
|
Hi Sandy, I have attempted the following: #!/usr/bin/perl=20 use strict;=20 use Net::SSH::Perl;=20 my $user =3D "root";=20 my $pass =3D "password";=20 my $host =3D "192.168.0.173";=20 my $cmd =3D "cat /proc/meminfo";=20 my $ssh =3D Net::SSH::Perl->new($host);=20 $ssh->login($user, $pass);=20 my($stdout, $stderr, $exit) =3D $ssh->cmd($cmd);=20 =20 I get the following error, even though I have installed libnet-ssh-perl on my debian Linux server. Can't locate Net/SSH/Perl.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.4 /usr/local/share/perl/5.8.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at 1023-sessions-delete500-memorySqueeze.pl line 8. BEGIN failed--compilation aborted at 1023-sessions-delete500-memorySqueeze.pl line 8. There were 2 Failures in Test Case 1023-sessions-delete500-memorySqueeze.pl |
From: Sander P. <San...@da...> - 2006-03-30 00:05:37
|
Sorry, forgot to copy the list. ________________________________ From: Sander Pool=20 Sent: Wednesday, March 29, 2006 4:05 PM To: 'Bobby Jafari' Subject: RE: [Ssh-sftp-perl-users] Need help with Net::SSH2 =20 Bobby, =20 not sure what an unnaturalized value is, sorry. I use Net::SSH::Perl with password authentication. Check the 'login' method. =20 Sander ________________________________ From: ssh...@li... [mailto:ssh...@li...] On Behalf Of Bobby Jafari Sent: Wednesday, March 29, 2006 3:58 PM To: ssh...@li... Subject: [Ssh-sftp-perl-users] Need help with Net::SSH2 Hi All,=20 What I am trying to do is connect to Embedded Linux devices and run Linux command remotely. The perl scripts will be running on a debian Linux server. I have installed the following packages on the debian Linux Server: Net-SSH2-0.07=20 libssh2-0.13=20 openssl-0.9.8a=20 Zlib1g-dev=20 Libterm-readkey-perl=20 Net::SSH::Perl=20 My script is:=20 #!/usr/bin/perl=20 use strict;=20 use Net::SSH2;=20 my $user =3D "root";=20 my $pass =3D "password";=20 my $host =3D "192.168.0.173";=20 my $ssh2 =3D Net::SSH2 -> new ( );=20 $ssh2->auth_password($user, $pass);=20 $ssh2->connect($host);=20 The problem is that the last line always complains about an unnaturalized value. I also can't figure out how to send a Linux command once I have a connection? Using RSA authentication is out of the question due to the environment that I am running the tests. I don't think I can use the module Net::SSH:Perl as It doesn't seem to support password authentication. If anyone knows how to use Net::SSH:Perl with password authentication please let me know. Also any help with Net:SSH2 would be mostly appreciated.=20 Thanks for your help.=20 Bobby Jafari Test Engineer Senetas Security Pty Ltd Office: +61 3 9868 4529 Mobile: +61 404 089 021 E-Mail: bob...@se...=20 |
From: Bobby J. <bob...@se...> - 2006-03-29 23:58:38
|
Hi All, What I am trying to do is connect to Embedded Linux devices and run Linux command remotely. The perl scripts will be running on a debian Linux server. I have installed the following packages on the debian Linux Server: Net-SSH2-0.07 libssh2-0.13 openssl-0.9.8a Zlib1g-dev Libterm-readkey-perl Net::SSH::Perl My script is: #!/usr/bin/perl use strict; use Net::SSH2; my $user =3D "root"; my $pass =3D "password"; my $host =3D "192.168.0.173"; my $ssh2 =3D Net::SSH2 -> new ( ); $ssh2->auth_password($user, $pass); $ssh2->connect($host); The problem is that the last line always complains about an unnaturalized value. I also can't figure out how to send a Linux command once I have a connection? Using RSA authentication is out of the question due to the environment that I am running the tests. I don't think I can use the module Net::SSH:Perl as It doesn't seem to support password authentication. If anyone knows how to use Net::SSH:Perl with password authentication please let me know. Also any help with Net:SSH2 would be mostly appreciated. Thanks for your help. Bobby Jafari Test Engineer Senetas Security Pty Ltd Office: +61 3 9868 4529 Mobile: +61 404 089 021 E-Mail: bob...@se... |
From: Eric L. <net...@er...> - 2006-03-27 16:26:13
|
I looked through the example some more and compared it to what you are doing. If I understand how your system works correctly, after logging in through ssh, you are immediately prompted for a login to whatever subsystem you are trying to access. You don't have to issue a command to initiate the second login sequence right? You might want to try breaking up the username password stuff from line 31. Just send username at that prompt rather than sending both. Also may want to try removing the new lines. Probably not the problem, but it's worth a shot. Also worth looking into how you are doing the send data steps since between lines 31 and 36 you are building them differently. > -----Original Message----- > From: ssh...@li... > [mailto:ssh...@li...] On > Behalf Of Matthew J. Salerno > Sent: Monday, March 27, 2006 8:05 AM > To: Eric Langheinrich; Vag...@ya...; > ssh...@li... > Subject: RE: [Ssh-sftp-perl-users] Interfacing with network > appliance through ssh > > Thanks for the suggestion, I tried it, but I get the same results. > > --- Eric Langheinrich <net...@er...> > wrote: > > > > > > > > > I think I might have found part of the problem, > > maybe... > > > > > > When you call: $ssh->cmd("$cmd"); > > > > > > I believe that it waits for an exit code from > > whatever it is > > > executing. In my case, I am not executing > > anything, > > > therefore I wont receive an exit code. > > > > > > I guess that I need to setup my own channel and > > not use $ssh->cmd. > > > > > > > I was looking at this again today and at the Net::SSH::Perl docs. > > > > A couple of things came to mind. > > > > First, you may want to try enabling interactive. I believe > to interact > > with a prompt you do not want to be running in batch mode. You may > > also have to allocate a tty depending on the requirements of your > > program. > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection > around http://mail.yahoo.com > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking > scripting language > that extends applications into web and mobile media. Attend > the live webcast > and join the prime developer group breaking into this new > coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& dat=121642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > |
From: Michael A C. <mac...@us...> - 2006-03-27 15:09:25
|
For the purpose of testing use the CGI::Carp (http://search.cpan.org/~lds/CGI.pm-3.17/CGI/Carp.pm) module. This will send any fatal error info. to the browser and give you a better idea of what is happening rather than a generic http error status. Just remember to take it out once you go live ;-). -Mike Srinivasan Viswanathan <sri...@ya...> Sent by: ssh...@li... 03/26/2006 01:18 AM To Eric Langheinrich <net...@er...>, ssh...@li... cc Subject RE: [Ssh-sftp-perl-users] SSH Web page not working yes, i did. There is no logs on the webserver. --- Eric Langheinrich <net...@er...> wrote: > > > > > Hello, Following program works fine through > command line, > > same code is not working through Web PAGE...Please > see whats wrong.... > > Have you looked at your web logs to see what errors > are being generated? > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ Ssh-sftp-perl-users mailing list Ssh...@li... https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users |
From: Matthew J. S. <vag...@ya...> - 2006-03-27 15:05:10
|
Thanks for the suggestion, I tried it, but I get the same results. --- Eric Langheinrich <net...@er...> wrote: > > > > > I think I might have found part of the problem, > maybe... > > > > When you call: $ssh->cmd("$cmd"); > > > > I believe that it waits for an exit code from > whatever it is > > executing. In my case, I am not executing > anything, > > therefore I wont receive an exit code. > > > > I guess that I need to setup my own channel and > not use $ssh->cmd. > > > > I was looking at this again today and at the > Net::SSH::Perl docs. > > A couple of things came to mind. > > First, you may want to try enabling interactive. I > believe to interact with > a prompt you do not want to be running in batch > mode. You may also have to > allocate a tty depending on the requirements of your > program. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Eric L. <net...@er...> - 2006-03-26 14:11:40
|
> yes, i did. There is no logs on the webserver. > What do you get in your browser when you access the page? What problems do you experience when you access as a web page rather than running it from the command line? |
From: Srinivasan V. <sri...@ya...> - 2006-03-26 06:18:11
|
yes, i did. There is no logs on the webserver. --- Eric Langheinrich <net...@er...> wrote: > > > > > Hello, Following program works fine through > command line, > > same code is not working through Web PAGE...Please > see whats wrong.... > > Have you looked at your web logs to see what errors > are being generated? > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Eric L. <net...@er...> - 2006-03-25 22:56:32
|
> > I think I might have found part of the problem, maybe... > > When you call: $ssh->cmd("$cmd"); > > I believe that it waits for an exit code from whatever it is > executing. In my case, I am not executing anything, > therefore I wont receive an exit code. > > I guess that I need to setup my own channel and not use $ssh->cmd. > I was looking at this again today and at the Net::SSH::Perl docs. A couple of things came to mind. First, you may want to try enabling interactive. I believe to interact with a prompt you do not want to be running in batch mode. You may also have to allocate a tty depending on the requirements of your program. |
From: Eric L. <net...@er...> - 2006-03-25 22:39:20
|
> > Hello, Following program works fine through command line, > same code is not working through Web PAGE...Please see whats wrong.... Have you looked at your web logs to see what errors are being generated? |
From: Srinivasan V. <sri...@ya...> - 2006-03-25 22:24:55
|
Hello, Following program works fine through command line, same code is not working through Web PAGE...Please see whats wrong.... #!/usr/bin/perl -s use Net::SSH::Perl; print <<"EOF"; Content-type: text/html <HTML><BODY> EOF my $ssh = Net::SSH::Perl->new("hostname", protocol=>'2', debug=>"true"); # $ssh = Net::SSH::Perl->new("hostname"); print "after init"; my ($stdout, $stderr, $exit) = $ssh->login("username","password","true"); print ("$stdout\n"); print ("$stderr\n"); print ("$exit\n"); print "after login"; print $ssh->cmd('ls -l'); print "completed"; print <<"EOF"; </BODY> </HTML> EOF __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Sander P. <San...@da...> - 2006-03-24 19:07:37
|
Christophe, =20 there is an example in the package that deals with this sort of thing. You basically set up custom handlers for incoming data. I could not get it to work though so I reverted to using Net::telnet for that situation. Perhaps Net::SSH2 is better suited? =20 Sander ________________________________ From: ssh...@li... [mailto:ssh...@li...] On Behalf Of Christophe CHAMPENOIS Sent: Friday, March 24, 2006 9:19 AM To: ssh...@li... Subject: [Ssh-sftp-perl-users] Confirmation neede by a script. Hi =20 Now, I can connet to my host with my perl script (and Net::ssh::perl). I can also execute a script. =20 My script looks like this =20 my $ssh =3D Net::SSH::Perl->new($host); $ssh->login($user,$pass); my($stdout, $stderr, $exit) =3D $ssh->cmd("mycommand"); =20 But when mycommand is executed, it asks a confirmation. If I execute mycommand locally: # ./mycommand Are you sure you want to proceed? . So, I have to respond yes to this message. How can I respond to that? Is it possible? =20 Thanks =20 |
From: Christophe C. <chr...@un...> - 2006-03-24 17:19:08
|
Hi =20 Now, I can connet to my host with my perl script (and Net::ssh::perl). I can also execute a script. =20 My script looks like this =20 my $ssh =3D Net::SSH::Perl->new($host); $ssh->login($user,$pass); my($stdout, $stderr, $exit) =3D $ssh->cmd("mycommand"); =20 But when mycommand is executed, it asks a confirmation. If I execute mycommand locally: # ./mycommand Are you sure you want to proceed? . So, I have to respond yes to this message. How can I respond to that? Is it possible? =20 Thanks =20 |
From: Matthew J. S. <vag...@ya...> - 2006-03-23 23:23:00
|
I think I might have found part of the problem, maybe... When you call: $ssh->cmd("$cmd"); I believe that it waits for an exit code from whatever it is executing. In my case, I am not executing anything, therefore I wont receive an exit code. I guess that I need to setup my own channel and not use $ssh->cmd. I can't be the only preson who has come across a situation like this. Anyone have any suggestions? Here is what the putty logs look like: <Just hit enter after entering username> Outgoing packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) Incoming packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) ..........Password: Outgoing packet type 94 / 0x5e (SSH2_MSG_CHANNEL_DATA) Incoming packet type 2 / 0x02 (SSH2_MSG_IGNORE) --- "Matthew J. Salerno" <vag...@ya...> wrote: > If I use Data::Dumper to view the buffer, I see that > what gets returned is an already failed > authentication > attempt. Is there anything else I should check? > > Thanks, > > Matt > > my $i = 0; > > $ssh->register_handler("stdout", sub { > $i++; > my($channel, $buffer) = @_; > print Dumper $buffer; > my $str = $buffer->bytes; > my $getsrt = $buffer->get_str; > print "\nSTR $i: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER $i\n"; > $channel->send_data("$user\n"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD $i\n"; > $channel->send_data("$pw"); > } > }); > > my ($stdout, $stderr, $exit) = $ssh->cmd($user); > > Output: > > > Logging In > $VAR1 = bless( { > '_get_mp_int' => sub { "DUMMY" }, > '_put_mp_int' => sub { "DUMMY" }, > 'buf' => 'Welcome to Webstream > Server > > Username: ', > 'offset' => 0 > }, 'Net::SSH::Perl::Buffer' ); > > STR 1: Welcome to Webstream Server > > Username: > END > > USER 1 > $VAR1 = bless( { > '_get_mp_int' => sub { "DUMMY" }, > '_put_mp_int' => sub { "DUMMY" }, > 'buf' => 'Password: > Could not read password. > Authenticating [username2]..... > Authentication Failed. Good bye. [0x9] > ', > 'offset' => 0 > }, 'Net::SSH::Perl::Buffer' ); > > STR 2: Password: > Could not read password. > Authenticating [username2]..... > Authentication Failed. Good bye. [0x9] > > END > > > PASSWORD 2 > EXIT 255 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-03-23 14:52:40
|
If I use Data::Dumper to view the buffer, I see that what gets returned is an already failed authentication attempt. Is there anything else I should check? Thanks, Matt my $i = 0; $ssh->register_handler("stdout", sub { $i++; my($channel, $buffer) = @_; print Dumper $buffer; my $str = $buffer->bytes; my $getsrt = $buffer->get_str; print "\nSTR $i: $str\nEND\n\n"; if ($str =~ /Username: $/) { print "USER $i\n"; $channel->send_data("$user\n"); } elsif ($str =~ /Password/i) { print "\nPASSWORD $i\n"; $channel->send_data("$pw"); } }); my ($stdout, $stderr, $exit) = $ssh->cmd($user); Output: Logging In $VAR1 = bless( { '_get_mp_int' => sub { "DUMMY" }, '_put_mp_int' => sub { "DUMMY" }, 'buf' => 'Welcome to Webstream Server Username: ', 'offset' => 0 }, 'Net::SSH::Perl::Buffer' ); STR 1: Welcome to Webstream Server Username: END USER 1 $VAR1 = bless( { '_get_mp_int' => sub { "DUMMY" }, '_put_mp_int' => sub { "DUMMY" }, 'buf' => 'Password: Could not read password. Authenticating [username2]..... Authentication Failed. Good bye. [0x9] ', 'offset' => 0 }, 'Net::SSH::Perl::Buffer' ); STR 2: Password: Could not read password. Authenticating [username2]..... Authentication Failed. Good bye. [0x9] END PASSWORD 2 EXIT 255 --- Eric Langheinrich <er...@er...> wrote: > What happens if instead of: > > $ssh->register_handler("stdout", sub { > my($channel, $buffer) = @_; > my $str = $buffer->bytes; > print "\nSTR: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER2\n"; > $channel->send_data("$user\n$pw\n"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD2\n"; > $channel->send_data($pw,"\n"); > } > > You use: > > $ssh->register_handler("stdout", sub { > my($channel, $buffer) = @_; > my $str = $buffer->bytes; > print "\nSTR: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER2\n"; > $channel->send_data("$user"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD2\n"; > $channel->send_data($pw,"\n"); > } > > > -----Original Message----- > > From: > ssh...@li... > > > [mailto:ssh...@li...] > On > > Behalf Of Matthew J. Salerno > > Sent: Wednesday, March 22, 2006 10:24 AM > > To: Eric Langheinrich; > ssh...@li... > > Subject: RE: [Ssh-sftp-perl-users] Interfacing > with network > > appliance through ssh > > > > What really confuses me, is when I am printing my > $str = > > $buffer->bytes; > > > > When I print print "STR: $str\nEND"; looking for > the username > > prompt, it looks normal, I get: > > > > STR: Welcome to Raritan Dominion Server > > > > Username: > > END > > > > > > But when I print "STR: $str\nEND"; looking for the > password > > prompt, I get: > > > > STR: Password: > > Could not read password. > > Authenticating []..... > > Authentication Failed. Good bye. [0x9] > > > > END > > > > > > I'm not sure why the buffer would contain failed > attempts. > > Shouldn't it just contain the Passowrd: > > line? > > > > > > > > --- Eric Langheinrich <net...@er...> > > wrote: > > > > > Wouldn't it just be simpler to use public key > auth? > > > Do you really want to > > > have scripts with your passwords hard coded? > > > > > > Have you tried doing the login as a single step, > like so: > > > $ssh->login($user, $pass); > > > > > > Here's a sample of one I have working using > public > > > key: > > > > > > #!/usr/bin/perl > > > > > > Use strict; > > > Use Net::SSH::Perl; > > > My @ident = ("/home/user/.ssh/id_dsa"); my > %params = ( > > > protocol => 2, > > > interactive => 0, > > > identity_files => [@ident], > > > debug => 0, > > > options => [ > > > "BatchMode yes", > > > "AuthenticationSuccessMsg no", > > > "ForwardX11 no", > > > "ForwardAgent no" > > > ] > > > ); > > > > > > my $server = $ARGV[0]; > > > &sshconnect($server); > > > > > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > > > > > > print "$stdout\n"; > > > > > > if (! $ssh) { > > > print "Unable to establish ssh > connection > > > to: $server\n"; > > > } else { > > > print "Successfully established ssh > connection to: > > $server\n"; > > > } > > > > > > sub sshconnect { > > > my $server = $_[0]; > > > our $ssh = > Net::SSH::Perl->new("$server", %params); > > > $ssh->login("user"); > > > } > > > > > > Here is an example using username/password > login: > > > > > > #/usr/bin/perl > > > > > > use strict; > > > use Net::SSH::Perl; > > > use vars qw($ssh); > > > > > > > > > my %params = ( > > > protocol => 2, > > > interactive => 0, > > > debug => 0, > > > options => [ > > > "BatchMode yes", > > > "AuthenticationSuccessMsg no", > > > "ForwardX11 no", > > > "ForwardAgent no" > > > ] > > > ); > > > > > > my $pass = "password"; > > > > > > my $server = $ARGV[0]; > > > &sshconnect($server); > > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > print > > "$stdout\n"; if > > > (! $ssh) { > > > print "Unable to establish ssh > connection > > > to: $server\n"; > > > } else { > > > print "Successfully established ssh > connection to: > > $server\n"; > > > } > > > > > > sub sshconnect { > > > my $server = $_[0]; > > > our $ssh = > Net::SSH::Perl->new("$server", %params); > > > $ssh->login("user", $pass); > > > } > > > > > > > > > Hope this helps. > > > > > > > > > > -----Original Message----- > > > > From: > > > ssh...@li... > > > > > > > > > > [mailto:ssh...@li...] > > > On > > > > Behalf Of Matthew J. Salerno > > > > Sent: Wednesday, March 22, 2006 8:55 AM > > > > To: ssh...@li... > > > > Subject: [Ssh-sftp-perl-users] Interfacing > with > > > network > > > > appliance through ssh > > > > > > > > I have been going nuts trying to get this to > work. > > > > > > > Any help is appreciated. > > > > > > > > > > > > I need to automate the process of logging in > to a > > > network > > > > appliance and executing a few commands. The > > > network > > > > appliance uses: OpenSSH 3.8.1 > > > > > > > > The system I am executing from is using: > > > > Redhat Linux > > > > Net::SSH::Perl 1.30 > > > > Perl 5.8.5 > > > > > > > > Here is the login process, step-by-step: > > > > # ssh username1@10.10.10.15 > > > > > > > > Then I get prompted for another username as > > > expected. > > > > > > > > Welcome to Webstream Server > > > > > > > > Username: <Enter Username> > > > > > > > > Get prompted for > > > > Password: <Enter Password> > > > > > > > > This is where I am stuck. I have been working > on > > > the login > > > > process for a few days now, and I still cant > pass > > > the server > > > > the password. I can easily get to the point > where > > > it prompts > > > > for the password, but it does not work. Any > help > > > would be > > > > greatly appreciated. > > > > Here is what I have so far: > > > > > > > > #!/usr/bin/perl -w > > > > use strict; > > > > use Net::SSH::Perl; > > > > > > > > my %params; > > > > $params{"debug"} = 0; > > > > $params{"port"} = 22; > > > > $params{"protocol"} = 2; > > > > $params{"interactive"} = 0; > > > > $params{"compression"} = 0; > > > > $params{"PreferredAuthentications"} = > 'password'; > > > > $params{"PubkeyAuthentication"} = 'no'; > > $params{"RSAAuthentication"} > > > > = 'no'; > > > $params{"use_pty"} = 0; > > > > > > > > my $host = "10.10.10.15"; > > > > my $ruser = "username1"; > > > > my $user = 'username2'; > > > > my $pw = 'mypassword'; > > > > > > > > my $ssh = new Net::SSH::Perl($host, %params) > || > > > > die "Cannot Connect to system $! > $@\n"; > > > > > > > > print "Logging In\n"; > > > > $ssh->login($ruser) || die "Cannot Login $! > $@\n"; > > > > > > > > $ssh->register_handler("stdout", sub { > > > > my($channel, $buffer) = @_; > > > > my $str = $buffer->bytes; > > > > print "\nSTR: $str\nEND\n\n"; > > > > > > > > if ($str =~ /Username: $/) { > > > > print "USER2\n"; > > > > $channel->send_data("$user\n$pw\n"); > > > > } > > > > > > > > elsif ($str =~ /Password/i) { > > > > print "\nPASSWORD2\n"; > > > > $channel->send_data($pw,"\n"); > > > > } > > > > }); > > > > > > > > my ($stdout, $stderr, $exit) = > $ssh->cmd($user); > > > > > > > > print "\n\nSTDOUT - $stdout\n" if $stdout; > print > > > "STDERR - > > > > $stderr\n" if $stderr; print "EXIT $exit\n" if > > > $exit; > > > > > > > > exit; > > > > > > > > ---------- > > > > The results are: > > > > > > > > Logging In > > > > > > > > STR: Welcome to Webstream Server > > > > > > > > Username: > > > > END > > > > > > > > USER2 > > > > > > > > STR: Password: > > > > Could not read password. > > > > Authenticating [username2]..... > > > > Authentication Failed. Good bye. [0x9] > > > > > > > > END > > > > > > > > PASSWORD2 > > > > EXIT 255 > > > > > > > > > __________________________________________________ > > > > Do You Yahoo!? > > > > Tired of spam? Yahoo! Mail has the best spam > > > protection > > > > around http://mail.yahoo.com > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.Net email is sponsored by xPML, a > > > groundbreaking > > > > scripting language > > > > that extends applications into web and mobile > > > media. Attend > > > > the live webcast > > > > and join the prime developer group breaking > into > > > this new > > > > coding territory! > > > > > > > > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > > > dat=121642 > > > > > _______________________________________________ > > > > Ssh-sftp-perl-users mailing list > > > > Ssh...@li... > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > > > > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection > > around http://mail.yahoo.com > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a > groundbreaking > > scripting language > > that extends applications into web and mobile > media. Attend > > the live webcast > > and join the prime developer group breaking into > this new > > coding territory! > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > dat=121642 > > _______________________________________________ > > Ssh-sftp-perl-users mailing list > > Ssh...@li... > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Sander P. <San...@da...> - 2006-03-23 01:13:53
|
Hello, I have some scripts that use Net::ssh::perl to execute commands on our Linux based appliance. We recently upgraded the kernel level and I'm seeing some odd behavior that didn't occur with the previous one. If the box has sat for a while my script will execute fine but if I immediately run the script again it hangs when trying to execute a command over ssh. I turned debug to 1 and these are the last 4 lines of the output: sander.datadomain.com: Sending command: cifs enable sander.datadomain.com: Requesting service exec on channel 1. sander.datadomain.com: channel 1: open confirm rwindow 0 rmax 32768 sander.datadomain.com: input_channel_request: rtype exit-status reply 0 Can anyone shed any light on what the $ssh->cmd() call is waiting for? It appears that the command 'cifs enable' is not completing although I can not reproduce this by executing it by hand in an interactive ssh session (Putty). I'm trying to get the DUT to be more chatty to tell me what it's doing as well. Thanks, Sander =20 |
From: Matt F. <Mat...@no...> - 2006-03-22 20:47:34
|
I've just recently started using Net::SSH2. I just updated my install to 0.07, as I was getting the 0 byte files on the remote server using scp_put. I now get all of the data in the remote file, but the file modification time is wrong. I just ran the script using scp_put, but the file on the remote server has a modification time from two days ago. The local file has a modification time from today. Why am I getting a modification time from two days ago on the remote file? I'm thinking the timestamp on the remote file is the date/time when I first created this file, but I'm not sure of that. Matt -- "A foolish consistency is the hobgoblin of little minds, adored by little statesmen and philosophers and divines." -- Ralph Waldo Emerson |
From: Matthew J. S. <vag...@ya...> - 2006-03-22 19:08:42
|
If I make the suggested changes, I get the same results. The $str still prints out the same thing at the password prompt. Logging In STR: Welcome to Raritan Dominion Server Username: END USER2 STR: Password: Could not read password. Authenticating []..... Authentication Failed. Good bye. [0x9] END PASSWORD2 I'm happy to try any other suggestions. Thanks, Matt --- Eric Langheinrich <er...@er...> wrote: > What happens if instead of: > > $ssh->register_handler("stdout", sub { > my($channel, $buffer) = @_; > my $str = $buffer->bytes; > print "\nSTR: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER2\n"; > $channel->send_data("$user\n$pw\n"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD2\n"; > $channel->send_data($pw,"\n"); > } > > You use: > > $ssh->register_handler("stdout", sub { > my($channel, $buffer) = @_; > my $str = $buffer->bytes; > print "\nSTR: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER2\n"; > $channel->send_data("$user"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD2\n"; > $channel->send_data($pw,"\n"); > } > > > -----Original Message----- > > From: > ssh...@li... > > > [mailto:ssh...@li...] > On > > Behalf Of Matthew J. Salerno > > Sent: Wednesday, March 22, 2006 10:24 AM > > To: Eric Langheinrich; > ssh...@li... > > Subject: RE: [Ssh-sftp-perl-users] Interfacing > with network > > appliance through ssh > > > > What really confuses me, is when I am printing my > $str = > > $buffer->bytes; > > > > When I print print "STR: $str\nEND"; looking for > the username > > prompt, it looks normal, I get: > > > > STR: Welcome to Raritan Dominion Server > > > > Username: > > END > > > > > > But when I print "STR: $str\nEND"; looking for the > password > > prompt, I get: > > > > STR: Password: > > Could not read password. > > Authenticating []..... > > Authentication Failed. Good bye. [0x9] > > > > END > > > > > > I'm not sure why the buffer would contain failed > attempts. > > Shouldn't it just contain the Passowrd: > > line? > > > > > > > > --- Eric Langheinrich <net...@er...> > > wrote: > > > > > Wouldn't it just be simpler to use public key > auth? > > > Do you really want to > > > have scripts with your passwords hard coded? > > > > > > Have you tried doing the login as a single step, > like so: > > > $ssh->login($user, $pass); > > > > > > Here's a sample of one I have working using > public > > > key: > > > > > > #!/usr/bin/perl > > > > > > Use strict; > > > Use Net::SSH::Perl; > > > My @ident = ("/home/user/.ssh/id_dsa"); my > %params = ( > > > protocol => 2, > > > interactive => 0, > > > identity_files => [@ident], > > > debug => 0, > > > options => [ > > > "BatchMode yes", > > > "AuthenticationSuccessMsg no", > > > "ForwardX11 no", > > > "ForwardAgent no" > > > ] > > > ); > > > > > > my $server = $ARGV[0]; > > > &sshconnect($server); > > > > > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > > > > > > print "$stdout\n"; > > > > > > if (! $ssh) { > > > print "Unable to establish ssh > connection > > > to: $server\n"; > > > } else { > > > print "Successfully established ssh > connection to: > > $server\n"; > > > } > > > > > > sub sshconnect { > > > my $server = $_[0]; > > > our $ssh = > Net::SSH::Perl->new("$server", %params); > > > $ssh->login("user"); > > > } > > > > > > Here is an example using username/password > login: > > > > > > #/usr/bin/perl > > > > > > use strict; > > > use Net::SSH::Perl; > > > use vars qw($ssh); > > > > > > > > > my %params = ( > > > protocol => 2, > > > interactive => 0, > > > debug => 0, > > > options => [ > > > "BatchMode yes", > > > "AuthenticationSuccessMsg no", > > > "ForwardX11 no", > > > "ForwardAgent no" > > > ] > > > ); > > > > > > my $pass = "password"; > > > > > > my $server = $ARGV[0]; > > > &sshconnect($server); > > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > print > > "$stdout\n"; if > > > (! $ssh) { > > > print "Unable to establish ssh > connection > > > to: $server\n"; > > > } else { > > > print "Successfully established ssh > connection to: > > $server\n"; > > > } > > > > > > sub sshconnect { > > > my $server = $_[0]; > > > our $ssh = > Net::SSH::Perl->new("$server", %params); > > > $ssh->login("user", $pass); > > > } > > > > > > > > > Hope this helps. > > > > > > > > > > -----Original Message----- > > > > From: > > > ssh...@li... > > > > > > > > > > [mailto:ssh...@li...] > > > On > > > > Behalf Of Matthew J. Salerno > > > > Sent: Wednesday, March 22, 2006 8:55 AM > > > > To: ssh...@li... > > > > Subject: [Ssh-sftp-perl-users] Interfacing > with > > > network > > > > appliance through ssh > > > > > > > > I have been going nuts trying to get this to > work. > > > > > > > Any help is appreciated. > > > > > > > > > > > > I need to automate the process of logging in > to a > > > network > > > > appliance and executing a few commands. The > > > network > > > > appliance uses: OpenSSH 3.8.1 > > > > > > > > The system I am executing from is using: > > > > Redhat Linux > > > > Net::SSH::Perl 1.30 > > > > Perl 5.8.5 > > > > > > > > Here is the login process, step-by-step: > > > > # ssh username1@10.10.10.15 > > > > > > > > Then I get prompted for another username as > > > expected. > > > > > > > > Welcome to Webstream Server > > > > > > > > Username: <Enter Username> > > > > > > > > Get prompted for > > > > Password: <Enter Password> > > > > > > > > This is where I am stuck. I have been working > on > > > the login > > > > process for a few days now, and I still cant > pass > > > the server > > > > the password. I can easily get to the point > where > > > it prompts > > > > for the password, but it does not work. Any > help > > > would be > > > > greatly appreciated. > > > > Here is what I have so far: > > > > > > > > #!/usr/bin/perl -w > > > > use strict; > > > > use Net::SSH::Perl; > > > > > > > > my %params; > > > > $params{"debug"} = 0; > > > > $params{"port"} = 22; > > > > $params{"protocol"} = 2; > > > > $params{"interactive"} = 0; > > > > $params{"compression"} = 0; > > > > $params{"PreferredAuthentications"} = > 'password'; > > > > $params{"PubkeyAuthentication"} = 'no'; > > $params{"RSAAuthentication"} > > > > = 'no'; > > > $params{"use_pty"} = 0; > > > > > > > > my $host = "10.10.10.15"; > > > > my $ruser = "username1"; > > > > my $user = 'username2'; > > > > my $pw = 'mypassword'; > > > > > > > > my $ssh = new Net::SSH::Perl($host, %params) > || > > > > die "Cannot Connect to system $! > $@\n"; > > > > > > > > print "Logging In\n"; > > > > $ssh->login($ruser) || die "Cannot Login $! > $@\n"; > > > > > > > > $ssh->register_handler("stdout", sub { > > > > my($channel, $buffer) = @_; > > > > my $str = $buffer->bytes; > > > > print "\nSTR: $str\nEND\n\n"; > > > > > > > > if ($str =~ /Username: $/) { > > > > print "USER2\n"; > > > > $channel->send_data("$user\n$pw\n"); > > > > } > > > > > > > > elsif ($str =~ /Password/i) { > > > > print "\nPASSWORD2\n"; > > > > $channel->send_data($pw,"\n"); > > > > } > > > > }); > > > > > > > > my ($stdout, $stderr, $exit) = > $ssh->cmd($user); > > > > > > > > print "\n\nSTDOUT - $stdout\n" if $stdout; > print > > > "STDERR - > > > > $stderr\n" if $stderr; print "EXIT $exit\n" if > > > $exit; > > > > > > > > exit; > > > > > > > > ---------- > > > > The results are: > > > > > > > > Logging In > > > > > > > > STR: Welcome to Webstream Server > > > > > > > > Username: > > > > END > > > > > > > > USER2 > > > > > > > > STR: Password: > > > > Could not read password. > > > > Authenticating [username2]..... > > > > Authentication Failed. Good bye. [0x9] > > > > > > > > END > > > > > > > > PASSWORD2 > > > > EXIT 255 > > > > > > > > > __________________________________________________ > > > > Do You Yahoo!? > > > > Tired of spam? Yahoo! Mail has the best spam > > > protection > > > > around http://mail.yahoo.com > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > > This SF.Net email is sponsored by xPML, a > > > groundbreaking > > > > scripting language > > > > that extends applications into web and mobile > > > media. Attend > > > > the live webcast > > > > and join the prime developer group breaking > into > > > this new > > > > coding territory! > > > > > > > > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > > > dat=121642 > > > > > _______________________________________________ > > > > Ssh-sftp-perl-users mailing list > > > > Ssh...@li... > > > > > > > > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > > > > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection > > around http://mail.yahoo.com > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a > groundbreaking > > scripting language > > that extends applications into web and mobile > media. Attend > > the live webcast > > and join the prime developer group breaking into > this new > > coding territory! > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > dat=121642 > > _______________________________________________ > > Ssh-sftp-perl-users mailing list > > Ssh...@li... > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-03-22 17:24:03
|
What really confuses me, is when I am printing my $str = $buffer->bytes; When I print print "STR: $str\nEND"; looking for the username prompt, it looks normal, I get: STR: Welcome to Raritan Dominion Server Username: END But when I print "STR: $str\nEND"; looking for the password prompt, I get: STR: Password: Could not read password. Authenticating []..... Authentication Failed. Good bye. [0x9] END I'm not sure why the buffer would contain failed attempts. Shouldn't it just contain the Passowrd: line? --- Eric Langheinrich <net...@er...> wrote: > Wouldn't it just be simpler to use public key auth? > Do you really want to > have scripts with your passwords hard coded? > > Have you tried doing the login as a single step, > like so: $ssh->login($user, > $pass); > > Here's a sample of one I have working using public > key: > > #!/usr/bin/perl > > Use strict; > Use Net::SSH::Perl; > My @ident = ("/home/user/.ssh/id_dsa"); > my %params = ( > protocol => 2, > interactive => 0, > identity_files => [@ident], > debug => 0, > options => [ > "BatchMode yes", > "AuthenticationSuccessMsg no", > "ForwardX11 no", > "ForwardAgent no" > ] > ); > > my $server = $ARGV[0]; > &sshconnect($server); > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > > print "$stdout\n"; > > if (! $ssh) { > print "Unable to establish ssh connection > to: $server\n"; > } else { > print "Successfully established ssh > connection to: $server\n"; > } > > sub sshconnect { > my $server = $_[0]; > our $ssh = Net::SSH::Perl->new("$server", > %params); > $ssh->login("user"); > } > > Here is an example using username/password login: > > #/usr/bin/perl > > use strict; > use Net::SSH::Perl; > use vars qw($ssh); > > > my %params = ( > protocol => 2, > interactive => 0, > debug => 0, > options => [ > "BatchMode yes", > "AuthenticationSuccessMsg no", > "ForwardX11 no", > "ForwardAgent no" > ] > ); > > my $pass = "password"; > > my $server = $ARGV[0]; > &sshconnect($server); > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > print "$stdout\n"; > if (! $ssh) { > print "Unable to establish ssh connection > to: $server\n"; > } else { > print "Successfully established ssh > connection to: $server\n"; > } > > sub sshconnect { > my $server = $_[0]; > our $ssh = Net::SSH::Perl->new("$server", > %params); > $ssh->login("user", $pass); > } > > > Hope this helps. > > > > -----Original Message----- > > From: > ssh...@li... > > > [mailto:ssh...@li...] > On > > Behalf Of Matthew J. Salerno > > Sent: Wednesday, March 22, 2006 8:55 AM > > To: ssh...@li... > > Subject: [Ssh-sftp-perl-users] Interfacing with > network > > appliance through ssh > > > > I have been going nuts trying to get this to work. > > > Any help is appreciated. > > > > > > I need to automate the process of logging in to a > network > > appliance and executing a few commands. The > network > > appliance uses: OpenSSH 3.8.1 > > > > The system I am executing from is using: > > Redhat Linux > > Net::SSH::Perl 1.30 > > Perl 5.8.5 > > > > Here is the login process, step-by-step: > > # ssh username1@10.10.10.15 > > > > Then I get prompted for another username as > expected. > > > > Welcome to Webstream Server > > > > Username: <Enter Username> > > > > Get prompted for > > Password: <Enter Password> > > > > This is where I am stuck. I have been working on > the login > > process for a few days now, and I still cant pass > the server > > the password. I can easily get to the point where > it prompts > > for the password, but it does not work. Any help > would be > > greatly appreciated. > > Here is what I have so far: > > > > #!/usr/bin/perl -w > > use strict; > > use Net::SSH::Perl; > > > > my %params; > > $params{"debug"} = 0; > > $params{"port"} = 22; > > $params{"protocol"} = 2; > > $params{"interactive"} = 0; > > $params{"compression"} = 0; > > $params{"PreferredAuthentications"} = 'password'; > > $params{"PubkeyAuthentication"} = 'no'; > > $params{"RSAAuthentication"} = 'no'; > $params{"use_pty"} = 0; > > > > my $host = "10.10.10.15"; > > my $ruser = "username1"; > > my $user = 'username2'; > > my $pw = 'mypassword'; > > > > my $ssh = new Net::SSH::Perl($host, %params) || > > die "Cannot Connect to system $! $@\n"; > > > > print "Logging In\n"; > > $ssh->login($ruser) || die "Cannot Login $! $@\n"; > > > > $ssh->register_handler("stdout", sub { > > my($channel, $buffer) = @_; > > my $str = $buffer->bytes; > > print "\nSTR: $str\nEND\n\n"; > > > > if ($str =~ /Username: $/) { > > print "USER2\n"; > > $channel->send_data("$user\n$pw\n"); > > } > > > > elsif ($str =~ /Password/i) { > > print "\nPASSWORD2\n"; > > $channel->send_data($pw,"\n"); > > } > > }); > > > > my ($stdout, $stderr, $exit) = $ssh->cmd($user); > > > > print "\n\nSTDOUT - $stdout\n" if $stdout; print > "STDERR - > > $stderr\n" if $stderr; print "EXIT $exit\n" if > $exit; > > > > exit; > > > > ---------- > > The results are: > > > > Logging In > > > > STR: Welcome to Webstream Server > > > > Username: > > END > > > > USER2 > > > > STR: Password: > > Could not read password. > > Authenticating [username2]..... > > Authentication Failed. Good bye. [0x9] > > > > END > > > > PASSWORD2 > > EXIT 255 > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection > > around http://mail.yahoo.com > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a > groundbreaking > > scripting language > > that extends applications into web and mobile > media. Attend > > the live webcast > > and join the prime developer group breaking into > this new > > coding territory! > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > dat=121642 > > _______________________________________________ > > Ssh-sftp-perl-users mailing list > > Ssh...@li... > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Matthew J. S. <vag...@ya...> - 2006-03-22 17:18:50
|
From what I think I understand of the process, the issue really isnât about authentication. I understand the security implications of hardcoding usernames and passwords, but unfortunately, that is not an option at this time. The first step when I log in with the first username "username1", works. The second user and password prompt are probably more like entering commands than authenticating. I have tried using $ssh->login rather than $ssh->cmd for the second login, but I always get the error message: Protocol error: expected packet type 20, got 93 I am interpreting that as meaning that the second login is not really a login as the ssh server sees it. I could be very wrong though. I think that it's like logging into an ssh session and then rather than getting a command prompt, you get asked 2 questions. Or I am completely wrong. Not sure. --- Eric Langheinrich <net...@er...> wrote: > Wouldn't it just be simpler to use public key auth? > Do you really want to > have scripts with your passwords hard coded? > > Have you tried doing the login as a single step, > like so: $ssh->login($user, > $pass); > > Here's a sample of one I have working using public > key: > > #!/usr/bin/perl > > Use strict; > Use Net::SSH::Perl; > My @ident = ("/home/user/.ssh/id_dsa"); > my %params = ( > protocol => 2, > interactive => 0, > identity_files => [@ident], > debug => 0, > options => [ > "BatchMode yes", > "AuthenticationSuccessMsg no", > "ForwardX11 no", > "ForwardAgent no" > ] > ); > > my $server = $ARGV[0]; > &sshconnect($server); > > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > > print "$stdout\n"; > > if (! $ssh) { > print "Unable to establish ssh connection > to: $server\n"; > } else { > print "Successfully established ssh > connection to: $server\n"; > } > > sub sshconnect { > my $server = $_[0]; > our $ssh = Net::SSH::Perl->new("$server", > %params); > $ssh->login("user"); > } > > Here is an example using username/password login: > > #/usr/bin/perl > > use strict; > use Net::SSH::Perl; > use vars qw($ssh); > > > my %params = ( > protocol => 2, > interactive => 0, > debug => 0, > options => [ > "BatchMode yes", > "AuthenticationSuccessMsg no", > "ForwardX11 no", > "ForwardAgent no" > ] > ); > > my $pass = "password"; > > my $server = $ARGV[0]; > &sshconnect($server); > my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); > print "$stdout\n"; > if (! $ssh) { > print "Unable to establish ssh connection > to: $server\n"; > } else { > print "Successfully established ssh > connection to: $server\n"; > } > > sub sshconnect { > my $server = $_[0]; > our $ssh = Net::SSH::Perl->new("$server", > %params); > $ssh->login("user", $pass); > } > > > Hope this helps. > > > > -----Original Message----- > > From: > ssh...@li... > > > [mailto:ssh...@li...] > On > > Behalf Of Matthew J. Salerno > > Sent: Wednesday, March 22, 2006 8:55 AM > > To: ssh...@li... > > Subject: [Ssh-sftp-perl-users] Interfacing with > network > > appliance through ssh > > > > I have been going nuts trying to get this to work. > > > Any help is appreciated. > > > > > > I need to automate the process of logging in to a > network > > appliance and executing a few commands. The > network > > appliance uses: OpenSSH 3.8.1 > > > > The system I am executing from is using: > > Redhat Linux > > Net::SSH::Perl 1.30 > > Perl 5.8.5 > > > > Here is the login process, step-by-step: > > # ssh username1@10.10.10.15 > > > > Then I get prompted for another username as > expected. > > > > Welcome to Webstream Server > > > > Username: <Enter Username> > > > > Get prompted for > > Password: <Enter Password> > > > > This is where I am stuck. I have been working on > the login > > process for a few days now, and I still cant pass > the server > > the password. I can easily get to the point where > it prompts > > for the password, but it does not work. Any help > would be > > greatly appreciated. > > Here is what I have so far: > > > > #!/usr/bin/perl -w > > use strict; > > use Net::SSH::Perl; > > > > my %params; > > $params{"debug"} = 0; > > $params{"port"} = 22; > > $params{"protocol"} = 2; > > $params{"interactive"} = 0; > > $params{"compression"} = 0; > > $params{"PreferredAuthentications"} = 'password'; > > $params{"PubkeyAuthentication"} = 'no'; > > $params{"RSAAuthentication"} = 'no'; > $params{"use_pty"} = 0; > > > > my $host = "10.10.10.15"; > > my $ruser = "username1"; > > my $user = 'username2'; > > my $pw = 'mypassword'; > > > > my $ssh = new Net::SSH::Perl($host, %params) || > > die "Cannot Connect to system $! $@\n"; > > > > print "Logging In\n"; > > $ssh->login($ruser) || die "Cannot Login $! $@\n"; > > > > $ssh->register_handler("stdout", sub { > > my($channel, $buffer) = @_; > > my $str = $buffer->bytes; > > print "\nSTR: $str\nEND\n\n"; > > > > if ($str =~ /Username: $/) { > > print "USER2\n"; > > $channel->send_data("$user\n$pw\n"); > > } > > > > elsif ($str =~ /Password/i) { > > print "\nPASSWORD2\n"; > > $channel->send_data($pw,"\n"); > > } > > }); > > > > my ($stdout, $stderr, $exit) = $ssh->cmd($user); > > > > print "\n\nSTDOUT - $stdout\n" if $stdout; print > "STDERR - > > $stderr\n" if $stderr; print "EXIT $exit\n" if > $exit; > > > > exit; > > > > ---------- > > The results are: > > > > Logging In > > > > STR: Welcome to Webstream Server > > > > Username: > > END > > > > USER2 > > > > STR: Password: > > Could not read password. > > Authenticating [username2]..... > > Authentication Failed. Good bye. [0x9] > > > > END > > > > PASSWORD2 > > EXIT 255 > > > > __________________________________________________ > > Do You Yahoo!? > > Tired of spam? Yahoo! Mail has the best spam > protection > > around http://mail.yahoo.com > > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by xPML, a > groundbreaking > > scripting language > > that extends applications into web and mobile > media. Attend > > the live webcast > > and join the prime developer group breaking into > this new > > coding territory! > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& > dat=121642 > > _______________________________________________ > > Ssh-sftp-perl-users mailing list > > Ssh...@li... > > > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > > > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Eric L. <net...@er...> - 2006-03-22 16:44:11
|
Wouldn't it just be simpler to use public key auth? Do you really want to have scripts with your passwords hard coded? Have you tried doing the login as a single step, like so: $ssh->login($user, $pass); Here's a sample of one I have working using public key: #!/usr/bin/perl Use strict; Use Net::SSH::Perl; My @ident = ("/home/user/.ssh/id_dsa"); my %params = ( protocol => 2, interactive => 0, identity_files => [@ident], debug => 0, options => [ "BatchMode yes", "AuthenticationSuccessMsg no", "ForwardX11 no", "ForwardAgent no" ] ); my $server = $ARGV[0]; &sshconnect($server); my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); print "$stdout\n"; if (! $ssh) { print "Unable to establish ssh connection to: $server\n"; } else { print "Successfully established ssh connection to: $server\n"; } sub sshconnect { my $server = $_[0]; our $ssh = Net::SSH::Perl->new("$server", %params); $ssh->login("user"); } Here is an example using username/password login: #/usr/bin/perl use strict; use Net::SSH::Perl; use vars qw($ssh); my %params = ( protocol => 2, interactive => 0, debug => 0, options => [ "BatchMode yes", "AuthenticationSuccessMsg no", "ForwardX11 no", "ForwardAgent no" ] ); my $pass = "password"; my $server = $ARGV[0]; &sshconnect($server); my ($stdout, $stderr, $exit) = $ssh->cmd("ls"); print "$stdout\n"; if (! $ssh) { print "Unable to establish ssh connection to: $server\n"; } else { print "Successfully established ssh connection to: $server\n"; } sub sshconnect { my $server = $_[0]; our $ssh = Net::SSH::Perl->new("$server", %params); $ssh->login("user", $pass); } Hope this helps. > -----Original Message----- > From: ssh...@li... > [mailto:ssh...@li...] On > Behalf Of Matthew J. Salerno > Sent: Wednesday, March 22, 2006 8:55 AM > To: ssh...@li... > Subject: [Ssh-sftp-perl-users] Interfacing with network > appliance through ssh > > I have been going nuts trying to get this to work. > Any help is appreciated. > > > I need to automate the process of logging in to a network > appliance and executing a few commands. The network > appliance uses: OpenSSH 3.8.1 > > The system I am executing from is using: > Redhat Linux > Net::SSH::Perl 1.30 > Perl 5.8.5 > > Here is the login process, step-by-step: > # ssh username1@10.10.10.15 > > Then I get prompted for another username as expected. > > Welcome to Webstream Server > > Username: <Enter Username> > > Get prompted for > Password: <Enter Password> > > This is where I am stuck. I have been working on the login > process for a few days now, and I still cant pass the server > the password. I can easily get to the point where it prompts > for the password, but it does not work. Any help would be > greatly appreciated. > Here is what I have so far: > > #!/usr/bin/perl -w > use strict; > use Net::SSH::Perl; > > my %params; > $params{"debug"} = 0; > $params{"port"} = 22; > $params{"protocol"} = 2; > $params{"interactive"} = 0; > $params{"compression"} = 0; > $params{"PreferredAuthentications"} = 'password'; > $params{"PubkeyAuthentication"} = 'no'; > $params{"RSAAuthentication"} = 'no'; $params{"use_pty"} = 0; > > my $host = "10.10.10.15"; > my $ruser = "username1"; > my $user = 'username2'; > my $pw = 'mypassword'; > > my $ssh = new Net::SSH::Perl($host, %params) || > die "Cannot Connect to system $! $@\n"; > > print "Logging In\n"; > $ssh->login($ruser) || die "Cannot Login $! $@\n"; > > $ssh->register_handler("stdout", sub { > my($channel, $buffer) = @_; > my $str = $buffer->bytes; > print "\nSTR: $str\nEND\n\n"; > > if ($str =~ /Username: $/) { > print "USER2\n"; > $channel->send_data("$user\n$pw\n"); > } > > elsif ($str =~ /Password/i) { > print "\nPASSWORD2\n"; > $channel->send_data($pw,"\n"); > } > }); > > my ($stdout, $stderr, $exit) = $ssh->cmd($user); > > print "\n\nSTDOUT - $stdout\n" if $stdout; print "STDERR - > $stderr\n" if $stderr; print "EXIT $exit\n" if $exit; > > exit; > > ---------- > The results are: > > Logging In > > STR: Welcome to Webstream Server > > Username: > END > > USER2 > > STR: Password: > Could not read password. > Authenticating [username2]..... > Authentication Failed. Good bye. [0x9] > > END > > PASSWORD2 > EXIT 255 > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection > around http://mail.yahoo.com > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking > scripting language > that extends applications into web and mobile media. Attend > the live webcast > and join the prime developer group breaking into this new > coding territory! > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720& dat=121642 > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > |
From: Matthew J. S. <vag...@ya...> - 2006-03-22 15:54:54
|
I have been going nuts trying to get this to work. Any help is appreciated. I need to automate the process of logging in to a network appliance and executing a few commands. The network appliance uses: OpenSSH 3.8.1 The system I am executing from is using: Redhat Linux Net::SSH::Perl 1.30 Perl 5.8.5 Here is the login process, step-by-step: # ssh username1@10.10.10.15 Then I get prompted for another username as expected. Welcome to Webstream Server Username: <Enter Username> Get prompted for Password: <Enter Password> This is where I am stuck. I have been working on the login process for a few days now, and I still cant pass the server the password. I can easily get to the point where it prompts for the password, but it does not work. Any help would be greatly appreciated. Here is what I have so far: #!/usr/bin/perl -w use strict; use Net::SSH::Perl; my %params; $params{"debug"} = 0; $params{"port"} = 22; $params{"protocol"} = 2; $params{"interactive"} = 0; $params{"compression"} = 0; $params{"PreferredAuthentications"} = 'password'; $params{"PubkeyAuthentication"} = 'no'; $params{"RSAAuthentication"} = 'no'; $params{"use_pty"} = 0; my $host = "10.10.10.15"; my $ruser = "username1"; my $user = 'username2'; my $pw = 'mypassword'; my $ssh = new Net::SSH::Perl($host, %params) || die "Cannot Connect to system $! $@\n"; print "Logging In\n"; $ssh->login($ruser) || die "Cannot Login $! $@\n"; $ssh->register_handler("stdout", sub { my($channel, $buffer) = @_; my $str = $buffer->bytes; print "\nSTR: $str\nEND\n\n"; if ($str =~ /Username: $/) { print "USER2\n"; $channel->send_data("$user\n$pw\n"); } elsif ($str =~ /Password/i) { print "\nPASSWORD2\n"; $channel->send_data($pw,"\n"); } }); my ($stdout, $stderr, $exit) = $ssh->cmd($user); print "\n\nSTDOUT - $stdout\n" if $stdout; print "STDERR - $stderr\n" if $stderr; print "EXIT $exit\n" if $exit; exit; ---------- The results are: Logging In STR: Welcome to Webstream Server Username: END USER2 STR: Password: Could not read password. Authenticating [username2]..... Authentication Failed. Good bye. [0x9] END PASSWORD2 EXIT 255 __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: David R. <dbr...@cp...> - 2006-03-21 07:06:49
|
On Sunday March 19, 2006 13:25, Phillip Corchary wrote: > New, clean 1.29 Net::SSH:Perl on CentOS box. Working on building tools to > help manage 2000+ servers ... some servers might obviously be down at some > arbitrary point in time. Current, when my test script tries to access a down > server (either down hard, no ping, or sshd down), it just HANGS. Note I'm > using a non-standard SSH port (required, local policy), but all hosts seem > to work fine when up. > > Debug output looks like this: ... > This takes about 5 minutes, which is obviously a problem ... All hosts are > on 100/1000 ethernet and not more than 2-50ms away by ping. These are the > SSH options I'm using ... I thought this would give a a 2sec timeout, but > it's not working ... > > my %params = ( ... > options => [ > "ConnectTimeout=2", > ] > ); > Need Help! I am new to Perl, but I think I can write the proper response to > the timeout -- just it's not even detecting the timeout!!! What am I doing > wrong here????? :-) Not all ssh configuration options are handled by Net::SSH::Perl (for a list of those that are, see the source of Net::SSH::Perl::Config, e.g. using 'perldoc -m Net::SSH::Perl::Config' or by looking at the file in the distribution or install tree). To handle a timeout, look at the eval and alarm builtins ("perldoc -f alarm" "perldoc -f eval"); e.g. eval { local $SIG{ALRM} = sub { die "ALARM\n"; }; alarm 2; # send SIGALRM in ~2 seconds # put connection code here }; if ($@) { die $@ unless $@ eq "ALARM\n"; # handle timeout } > Phil Corchary > Denver, Colorado > phillip =dot= corchary <at> gmail =dot= com I'd also like to take this opportunity to tout Net::SSH2 (yet again) as the wave of the future in all things SSHy. You may prefer it to Net::SSH::Perl. -- Dave Isa. 40:31 |
From: Eric L. <net...@er...> - 2006-03-20 22:59:29
|
After running the latest set of updates on my RH ES3 box, I'm having trouble with public/private key authentication. Running a test script, I get the following during the authentication phase: Use of uninitialized value in numeric ge (>=) at /usr/lib/perl5/site_perl/5.8.0/Crypt/DH.pm line 84. Use of uninitialized value in numeric lt (<) at /usr/lib/perl5/site_perl/5.8.0/Crypt/DH.pm line 84. Essentially these errors repeat until I kill my script. Has anyone else run into this? Any ideas? Thanks in Advance Eric Langheinrich |