Find the answer to your Linux question:
Results 1 to 4 of 4
Hello All, I need to SSH from my perl script to a remote machine and then execute some commands in that SSH session. Please note that i need to automate ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2009
    Posts
    17

    Opening a ssh session and running from some commands on it


    Hello All,
    I need to SSH from my perl script to a remote machine and then execute some commands in that SSH session.
    Please note that i need to automate this process, so i can not supply the password from command line and i don't have the permission to install Net::SSH::Perl on my machine, i need to stick to basic perl. Moreover, i can not even use the SSH-KEYGEN to copy the key on remote machine because of perlission, so i have to give the password only, i don't know how. Supplying the password is one part of the problem. Another part of the problem is executing commands in that SSH session and getting their output.
    As per the standard stuff, i should be able use the following syntax for SSH:
    ssh username IP <command>
    But my remote machine is not a STANDARD unix machine and hence i can not execute the command like this in one step.
    I need to SSH to this server and then execute the command as a second step.
    Please suggest, i really need to know how to open the SSH session from perl, pass the password to it automatically and then executing any commands on it.
    Thanks in advance

  2. #2
    Just Joined!
    Join Date
    May 2011
    Location
    Central FL
    Posts
    91
    You say "my machine", but then that you don't have permission to install things? Is this really your machine? Sounds like you need to speak to the admins and get access for using keys or tell them that you cannot complete this task otherwise without insecurely storing/passing a password.

    A better start would be actually telling us what you are trying to accomplish overall. Rather than "I want to ssh without a password, without keys, from perl, without perl's net::ssh" "I am trying to write a program that will be able to get statistics from a remote machine" etc. The more specific, the easier it is to help.

    Also, since it will matter - and partially for curiosity - what are the two machines involved since you mention one is not "STANDARD"?

  3. #3
    Just Joined!
    Join Date
    Apr 2009
    Posts
    17
    Hello,
    Thanks for your reply. As for the operating system of remote machine, i don't know it. It is a very highly secured network element, so i should forget about thnking to copy any key files over there.
    And for my machine, it is not possible to install NEt::SSH::Perl, there is huge list of dependancies, so our manager is not convinced about its usage. And my machine is not directly connected to internet, so it is a hectic task to install the dependancies. So, i hope it makes my situation clear.
    And we don't have any security concerns on our machine, so please suggest the solution, don't think about security on mymachine. It is not connected to internet, it is just accessible in our internal network, so no worries for security.
    My actual task is to setup a perl script which runs periodically, connects to remote machine, executes few commands,captures the output and then i will be parsing that output to get something useful out of it. Hope the situation is clear to you now.




    Quote Originally Posted by dayid View Post
    You say "my machine", but then that you don't have permission to install things? Is this really your machine? Sounds like you need to speak to the admins and get access for using keys or tell them that you cannot complete this task otherwise without insecurely storing/passing a password.

    A better start would be actually telling us what you are trying to accomplish overall. Rather than "I want to ssh without a password, without keys, from perl, without perl's net::ssh" "I am trying to write a program that will be able to get statistics from a remote machine" etc. The more specific, the easier it is to help.

    Also, since it will matter - and partially for curiosity - what are the two machines involved since you mention one is not "STANDARD"?

  4. #4
    Just Joined!
    Join Date
    May 2011
    Location
    Central FL
    Posts
    91
    Quote Originally Posted by nitesh View Post
    Hope the situation is clear to you now.
    Not at all, you still didn't explain what the situation of the two machines are, what OSs you are dealing with, nor any specifics of what you're trying to accomplish.

    If security isn't an issue at all (as you said), then just setup expect+telnet (or just pipe into telnet) - remove the password for the remote user, and be done with it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •