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

Hello. First question here.

I am trying to get Perl to SSH to a Unix machine. The possible origin machines are Unix, Linux and Windows XP. The problem is, it is all behind a very restrictive firewall (no FTP, authenticating HTTP that PPM cannot get through even I set up HTTP_proxy*).

I have Perl installed in the three machines, and all three have SSH clients (PuTTY in Windows). But I cannot get Open2($r, $w, "ssh destination") to work (I cannot do the SSH public key authentication, I cannot meddle with the destination machine) and I cannot use CPAN nor PPM to connect to a repository.

So I need help on how to do one of the following:

  1. Get Open2 to work with password authentication.
  2. Set a private repository and choose which files to put and where, to get CPAN / PPM to install Net::SSH, and get it to work with password authentication.
  3. Install the Net::SSH and all dependencies manually, and get it to work with password authentication.
  4. Something else you guys and girls think about.

Thanks in advance.

Replies are listed 'Best First'.
Re: Get Perl packages
by jasonk (Parson) on Jun 12, 2007 at 20:23 UTC

    Automating the regular ssh client will be much easier with Expect than with IPC::Open2...


    We're not surrounded, we're in a target-rich environment!

      I want to do SSH inside a Perl program because I want to do some complex stuff with the open SSH later.

      Like connect to 8 different machines, dive into directories, check what files are there, and depending on those files and in some stored values and on input parameters, run some Perl scripts on those remote files, get the results, process them, aggregate the results from the 8 different machines, and present them back.

      All this without being able to install anything in the remote machines, they are Production and cannot be touched.

      I do not know Expect that well, but I think I do need Perl for this.

Re: Get Perl packages
by MidLifeXis (Monsignor) on Jun 13, 2007 at 20:41 UTC

    I would probably (only from documentation, not use) try Net::SSH::Perl instead of Net::SSH, since the Net::SSH perldoc says:

    Q: How do you supply a password to connect with ssh within a perl script using the Net::SSH module?
    A: You don't. Use RSA or DSA keys. See the ssh-keygen(1) manpage.

    --MidLifeXis

      Thanks a lot.

      Now what I need is for someone to help me set up a local repository to install the package you recommend.