Loading ...
Sorry, an error occurred while loading the content.

Net::SSH::Perl

Expand Messages
  • Nguyen, David M
    Does anyone actually use Net::SSH::Perl module in scripting? I am trying to write a script using this module to access multiple hosts, execute multiple
    Message 1 of 13 , Jun 5, 2003
    • 0 Attachment
      Does anyone actually use Net::SSH::Perl module in scripting? I am
      trying to write a script using this module to access multiple hosts,
      execute multiple commands then capture output in a file. I also want to
      capture any errors to a specific file. How do I write code to do such
      things using this module? If someone has been there done that, please
      advise.


      Thanks,
      David
    • jaws
      Hi all, Below is my script: ======================================== #!/usr/bin/perl use Net::SSH::Perl; $user= jaws ; $pass= pass ;
      Message 2 of 13 , Sep 2, 2003
      • 0 Attachment
        Hi all,

        Below is my script:

        ========================================
        #!/usr/bin/perl

        use Net::SSH::Perl;
        $user="jaws";
        $pass="pass";
        $host="xxxx.xxxx.xxxx.xxxx";

        my $ssh = Net::SSH::Perl->new($host,"'1,2'");
        $ssh->login($user, $pass);
        $ssh->cmd("my_command");
        ========================================

        the output of the "my_command" requires me to input a username and password
        and this is my problem. Does anyone knows how to do it?

        Thanks.


        jaws

        ---------------
        Computer system security is a journey, not a destination.
      • Roger
        Hello, I have two servers A and B. In order to connect to server B, first I need to connect to server A and then connect to server B. I m able to connect to
        Message 3 of 13 , Sep 20, 2010
        • 0 Attachment
          Hello,

          I have two servers A and B. In order to connect to server B, first I need to connect to server A and then connect to server B. I'm able to connect to server A using Net::SSH::Perl.

          My question is, how do I connect to server B from server A using Net::SSH::Perl?

          Thanks,

          Roger





          [Non-text portions of this message have been removed]
        • merlyn@stonehenge.com
          ... Roger I have two servers A and B. In order to connect to server B, Roger first I need to connect to server A and then connect to server Roger B. I m
          Message 4 of 13 , Sep 20, 2010
          • 0 Attachment
            >>>>> "Roger" == Roger <rfbits@...> writes:

            Roger> I have two servers A and B. In order to connect to server B,
            Roger> first I need to connect to server A and then connect to server
            Roger> B. I'm able to connect to server A using Net::SSH::Perl.

            Roger> My question is, how do I connect to server B from server A using
            Roger> Net::SSH::Perl?

            The same way you connected from your original server to server A.

            As in, you have a program on Server A that uses Net::SSH::Perl
            to connect to server B.

            What part of this is complicated?

            --
            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
            Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
            See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
          • Roger
            Thanks for your response. I m running the below code (to connect to host A) from eclipse on my laptop. #!/usr/bin/perl   use Net::SSH::Perl; use strict; my
            Message 5 of 13 , Sep 20, 2010
            • 0 Attachment
              Thanks for your response.

              I'm running the below code (to connect to host A) from eclipse on my laptop.

              #!/usr/bin/perl
               
              use Net::SSH::Perl;
              use strict;

              my $refHost = "hostA";
              my $refUser = "userName";
              my $refPwd = "password!";
              my $refCmd = "ls -ltr";

              my $ssh = Net::SSH::Perl->new($refHost);
              $ssh->login($refUser, $refPwd);
              my($out, $err, $exit) = $ssh->cmd($refCmd);

              Now I need to connect to host B from host A. I want to do that from my laptop.

              Thanks,

              Roger

              --- On Mon, 9/20/10, merlyn@... <merlyn@...> wrote:

              From: merlyn@... <merlyn@...>
              Subject: Re: [PBML] Net::SSH::Perl
              To: "Roger" <rfbits@...>
              Cc: perl-beginner@yahoogroups.com
              Date: Monday, September 20, 2010, 5:42 PM







               









              >>>>> "Roger" == Roger <rfbits@...> writes:



              Roger> I have two servers A and B. In order to connect to server B,

              Roger> first I need to connect to server A and then connect to server

              Roger> B. I'm able to connect to server A using Net::SSH::Perl.



              Roger> My question is, how do I connect to server B from server A using

              Roger> Net::SSH::Perl?



              The same way you connected from your original server to server A.



              As in, you have a program on Server A that uses Net::SSH::Perl

              to connect to server B.



              What part of this is complicated?



              --

              Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

              <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>

              Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.

              See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion























              [Non-text portions of this message have been removed]
            • merlyn@stonehenge.com
              ... Roger Thanks for your response. Roger I m running the below code (to connect to host A) from eclipse on my laptop. Roger #!/usr/bin/perl Roger  
              Message 6 of 13 , Sep 20, 2010
              • 0 Attachment
                >>>>> "Roger" == Roger <rfbits@...> writes:

                Roger> Thanks for your response.
                Roger> I'm running the below code (to connect to host A) from eclipse on my laptop.

                Roger> #!/usr/bin/perl
                Roger>  
                Roger> use Net::SSH::Perl;
                Roger> use strict;

                Roger> my $refHost = "hostA";
                Roger> my $refUser = "userName";
                Roger> my $refPwd = "password!";
                Roger> my $refCmd = "ls -ltr";

                Roger> my $ssh = Net::SSH::Perl->new($refHost);
                Roger> $ssh->login($refUser, $refPwd);
                Roger> my($out, $err, $exit) = $ssh->cmd($refCmd);

                Roger> Now I need to connect to host B from host A. I want to do that
                Roger> from my laptop.

                Yup. Copy that code to HostA, edit it to point at HostB, and make sure
                Net::SSH::Perl is installed there.

                --
                Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
              • Paulo Pires
                One option is: You have a script in the serverA and your script execute this script to connect in the serveB. Paulo.Pires | אני יהוה Somente soldados
                Message 7 of 13 , Sep 20, 2010
                • 0 Attachment
                  One option is:

                  You have a script in the serverA and your script execute this script to connect in the serveB.




                  Paulo.Pires | אני יהוה



                  "Somente soldados feridos podem estar a serviço do amor"








                  To: perl-beginner@yahoogroups.com
                  From: rfbits@...
                  Date: Mon, 20 Sep 2010 17:52:30 -0700
                  Subject: Re: [PBML] Net::SSH::Perl






                  Thanks for your response.

                  I'm running the below code (to connect to host A) from eclipse on my laptop.

                  #!/usr/bin/perl

                  use Net::SSH::Perl;
                  use strict;

                  my $refHost = "hostA";
                  my $refUser = "userName";
                  my $refPwd = "password!";
                  my $refCmd = "ls -ltr";

                  my $ssh = Net::SSH::Perl->new($refHost);
                  $ssh->login($refUser, $refPwd);
                  my($out, $err, $exit) = $ssh->cmd($refCmd);

                  Now I need to connect to host B from host A. I want to do that from my laptop.

                  Thanks,

                  Roger

                  --- On Mon, 9/20/10, merlyn@... <merlyn@...> wrote:

                  From: merlyn@... <merlyn@...>
                  Subject: Re: [PBML] Net::SSH::Perl
                  To: "Roger" <rfbits@...>
                  Cc: perl-beginner@yahoogroups.com
                  Date: Monday, September 20, 2010, 5:42 PM



                  >>>>> "Roger" == Roger <rfbits@...> writes:

                  Roger> I have two servers A and B. In order to connect to server B,

                  Roger> first I need to connect to server A and then connect to server

                  Roger> B. I'm able to connect to server A using Net::SSH::Perl.

                  Roger> My question is, how do I connect to server B from server A using

                  Roger> Net::SSH::Perl?

                  The same way you connected from your original server to server A.

                  As in, you have a program on Server A that uses Net::SSH::Perl

                  to connect to server B.

                  What part of this is complicated?

                  --

                  Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

                  <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>

                  Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.

                  See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

                  [Non-text portions of this message have been removed]






                  [Non-text portions of this message have been removed]
                • Roger
                  Thanks. Problem is I don t have root permission to install the module in server A. ... From: merlyn@stonehenge.com Subject: Re: [PBML]
                  Message 8 of 13 , Sep 20, 2010
                  • 0 Attachment
                    Thanks. Problem is I don't have root permission to install the module in server A.

                    --- On Mon, 9/20/10, merlyn@... <merlyn@...> wrote:

                    From: merlyn@... <merlyn@...>
                    Subject: Re: [PBML] Net::SSH::Perl
                    To: "Roger" <rfbits@...>
                    Cc: perl-beginner@yahoogroups.com
                    Date: Monday, September 20, 2010, 5:59 PM







                     









                    >>>>> "Roger" == Roger <rfbits@...> writes:



                    Roger> Thanks for your response.

                    Roger> I'm running the below code (to connect to host A) from eclipse on my laptop.



                    Roger> #!/usr/bin/perl

                    Roger>  

                    Roger> use Net::SSH::Perl;

                    Roger> use strict;



                    Roger> my $refHost = "hostA";

                    Roger> my $refUser = "userName";

                    Roger> my $refPwd = "password!";

                    Roger> my $refCmd = "ls -ltr";



                    Roger> my $ssh = Net::SSH::Perl->new($refHost);

                    Roger> $ssh->login($refUser, $refPwd);

                    Roger> my($out, $err, $exit) = $ssh->cmd($refCmd);



                    Roger> Now I need to connect to host B from host A. I want to do that

                    Roger> from my laptop.



                    Yup. Copy that code to HostA, edit it to point at HostB, and make sure

                    Net::SSH::Perl is installed there.



                    --

                    Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095

                    <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>

                    Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.

                    See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion























                    [Non-text portions of this message have been removed]
                  • merlyn@stonehenge.com
                    ... Roger Thanks. Problem is I don t have root permission to install the Roger module in server A. You *never* need root permission to install a Perl module.
                    Message 9 of 13 , Sep 20, 2010
                    • 0 Attachment
                      >>>>> "Roger" == Roger <rfbits@...> writes:

                      Roger> Thanks. Problem is I don't have root permission to install the
                      Roger> module in server A.

                      You *never* need root permission to install a Perl module.

                      See "perldoc perlmodinstall".

                      And now... I'm obligated to include the following public
                      service announcement:

                      **************************************************
                      *
                      * THIS IS NOT THE OFFICIAL perl BEGINNERS GROUP.
                      *
                      * The official one is at beginners@..., with instructions on how to
                      * join at http://lists.perl.org/list/beginners.html.
                      *
                      * You'll get far better response there, not to say you won't get *any* here.
                      *
                      **************************************************

                      --
                      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                      Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                      See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
                    • off_gl@yahoo.com
                      I dont think you are right Merlyn ... Since I also tried to do the same thing and it didn t work for me too. you need to have root permission to install
                      Message 10 of 13 , Sep 20, 2010
                      • 0 Attachment
                        I dont think you are right Merlyn ... Since I also tried to do the same thing
                        and it didn't work for me too. you need to have root permission to install
                        NET::SSH::PERL module at least.


                        Roger I would suggest you to use shell script to connect to your laptop from
                        remote server..

                        And Merlyn this group name also suggest that it is for beginer
                        (perl-beginner@yahoogroups.com) if not then it should be changed .. No offense
                        but being a learner I am also facing the same issue ....

                        For better and interactive mode over ssh connection u can use the piece of code
                        given below Roger

                        #!/usr/bin/perl -w
                        use strict;
                        use Net::SSH::Perl;
                        my $host = '192.168.0.1';
                        my $username = 'user';
                        my $login_passwd = 'user123';
                        my $ssh = Net::SSH::Perl->new($host, $username);

                        $ssh->config->set('interactive', 1)
                        unless defined $ssh->config->get('interactive');
                        my $cmd;
                        $ssh->login($username, $login_passwd);

                        if ($cmd) {
                        my($out, $err, $exit) = $ssh->cmd($cmd);
                        print $out if $out;
                        print $err if $err;
                        }
                        else {
                        eval "use Term::ReadKey;";
                        ReadMode('raw');
                        eval "END { ReadMode('restore') };";
                        $ssh->shell;
                        print "Connection to $host closed.\n";
                        }

                        hope this helps ..




                        [Non-text portions of this message have been removed]
                      • merlyn@stonehenge.com
                        ... off I dont think you are right Merlyn ... Since I also tried to do the off same thing and it didn t work for me too. you need to have root off
                        Message 11 of 13 , Sep 20, 2010
                        • 0 Attachment
                          >>>>> "off" == off gl <off_gl@...> writes:

                          off> I dont think you are right Merlyn ... Since I also tried to do the
                          off> same thing and it didn't work for me too. you need to have root
                          off> permission to install NET::SSH::PERL module at least.

                          Please.
                          Read.
                          "perldoc perlmodinstall".

                          Please.

                          Don't say I'm not right without following that.

                          {sigh}

                          --
                          Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                          <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                          Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                          See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
                        • merlyn@stonehenge.com
                          ... off And Merlyn this group name also suggest that it is for beginer off (perl-beginner@yahoogroups.com) if not then it should be changed .. No offense
                          Message 12 of 13 , Sep 20, 2010
                          • 0 Attachment
                            >>>>> "off" == off gl <off_gl@...> writes:

                            off> And Merlyn this group name also suggest that it is for beginer
                            off> (perl-beginner@yahoogroups.com) if not then it should be changed .. No offense
                            off> but being a learner I am also facing the same issue ....

                            This group was created by idiots, who didn't realize there was
                            already an official group.

                            If I had the power to shut this group down, I would.

                            --
                            Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
                            <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
                            Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
                            See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
                          • Ralph Blach
                            I am using the module Net::SSH::Perl and i have successfully opened a terminal with ssh- shell The only problem is the the shell does not re-size and only
                            Message 13 of 13 , Nov 22, 2011
                            • 0 Attachment
                              I am using the module Net::SSH::Perl

                              and i have successfully opened a terminal with

                              ssh->shell

                              The only problem is the the shell does not re-size and only 80x25. How do change this?

                              How do I configure ssh->shell so that when I re-size the parent window, the child ssh shell changes.


                              Thank

                              Chip
                            Your message has been successfully submitted and would be delivered to recipients shortly.