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

Hello all, First off I'm relatively new to programming perl as I don't often need to. I am looking to write a program in which I am going to need an open an SSH to a domain. I have looked around and saw that I might be able to use the Net::SSH. I was wondering if there is any way to open up an SSh without having to install any software. If there is any good tutorials or sites you could give me I would appreciate it. John

Replies are listed 'Best First'.
Re: SSH help??
by sauoq (Abbot) on Jun 18, 2003 at 18:01 UTC

    If you are just going to ssh into a machine and run one command with something like ssh user@host.example.com ls -l then you might prefer to just use qx().

    You'll need to set up your trust relationships correctly, but you should really do that anyway because embedding a password in a script or even a configuration file isn't generally a good idea for any number of maintenance and security reasons.

    While it's true that Net::SSH::Perl will save you some process overhead, that might not be an issue for you at all. The real benefit is that it is an all-Perl implementation and won't even require that ssh be installed. On the other hand, it will require that several other modules be installed.

    -sauoq
    "My two cents aren't worth a dime.";
    
Re: SSH help??
by ScooterQ (Pilgrim) on Jun 18, 2003 at 17:02 UTC
    I'm sure that you could try to do it without installing a module, but the question is why would you? Someone else has already figured out all of the hard stuff you'd need to figure out in order to get ssh to work from within your program - leverage their work. You'll get your job done quicker and you won't be reinventing wheels.

    From the Net::SSH::Perl docs (Ben said this better than I did):

    One advantage to using Net::SSH::Perl over wrapper-style implementations of ssh clients is that it saves on process overhead: you no longer need to fork and execute a separate process in order to connect to an sshd. Depending on the amount of time and memory needed to fork a process, this win can be quite substantial; particularly if you're running in a persistent Perl environment (mod_perl, for example), where forking a new process is a drain on process and memory resources.
    It also simplifies the process of using password-based authentications; when writing a wrapper around ssh you probably need to use Expect to control the ssh client and give it your password. Net::SSH::Perl has built-in support for the authentication protocols, so there's no longer any hassle of communicating with any external processes.
      That is true and it would save me alot of time. I guess the next question is what module should I use. I have heard of Net::SSH and Net::SSH::Perl. Is there any suggestions or comments? Which one has less prereqs? Any advantages or disadvantages of either? Thanks, John

        Quite simply, Net::SSH::Perl rocks. I use it in a production environment with great success. There are a boatload of prereqs but don't let that put you off and once installed you'll be glad you persevered.

        -- vek --