swaroop has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I need to ssh to remote machine. Whenever I try to use Net::SSH module , its working fine in interactive mode ( issh ). But if I use batch mode ( ssh ) its failing , giving message no keys found.

How to add the keys through perl modules ? Please suggest. we can use ~/.ssh/config file. But its better if we are able to generate the key while running the script.

Thanks,
swaroop

  • Comment on ssh key ( known_hosts ) through perl module

Replies are listed 'Best First'.
Re: ssh key ( known_hosts ) through perl module
by gargle (Chaplain) on Aug 28, 2005 at 15:59 UTC

    Hi

    Without any code to see it's difficult to figure out what's going wrong.

    Could you post some code? It would help us :)

Re: ssh key ( known_hosts ) through perl module
by eXile (Priest) on Aug 28, 2005 at 16:20 UTC
    If Net::SSH doesn't do the job, you might want to use something like Expect to control the 'ssh' you have on your machine. See the tutorials section for a good intro on Expect.
Re: ssh key ( known_hosts ) through perl module
by Roger (Parson) on Aug 29, 2005 at 08:57 UTC
    Have you defined your ~/.ssh/authorized_keys?

Re: ssh key ( known_hosts ) through perl module
by newroz (Monk) on Aug 29, 2005 at 12:40 UTC
    Net::SSH uses publickey for method of authentication and it executes
    regular ssh. You should provide a publickey authentication mechanism to it.
    Then,you can use passwordless session. If you need generate key within script,have a lookCrypt::DSA and RSA version Crypt::RSA::Key
    Moreover,Why not using Net::SSH::Perl ?
      //Moreover,Why not using Net::SSH::Perl ? //

      Net::SSH::Perl module required authentication. I mean we need to specify the <username> and <password> in the script or interactively.

      Anyways, now using IO::open2 for ssh operation.

      Thanks,
      Swaroop