Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

SSH Help

by bear0053 (Hermit)
on Oct 29, 2004 at 02:10 UTC ( [id://403575]=perlquestion: print w/replies, xml ) Need Help??

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

fellow monks,
I am encountering the following problem:
i am trying to use sftp2 which is a command line program to log into a ssh server and put/get files from it during the exectution of my perl script.

The problem is that i call it like this:
my $pexec = `sftp2 username@host.com';
that starts the program and then prompts for a pwd. is there any way i can keep that shell open and continue to pass in parameters to the command line?

If not i am also trying to use Net::SSH:Perl but i can't install it for the life of me. I am trying to use the make file and it continually fails. it can't get past the Crypt::DSA install.

all help is appreciated thanks in advanced

Replies are listed 'Best First'.
Re: SSH Help
by itub (Priest) on Oct 29, 2004 at 03:45 UTC
    I remember I managed to install Net::SSH::Perl on Linux once, although it was a painful experience. What is your platform?
      win xp pro
        Since many of this module's dependencies require compilation and probably some external libraries, I'm afraid that installing in directly in Windows must be a titanic task. Perhaps in cygwin it will be easier.

        I would recommend using something like cygwin ssh or putty and public-key authentication, as others have suggested.

Re: SSH Help
by Anonymous Monk on Oct 29, 2004 at 06:24 UTC
Re: SSH Help
by Taulmarill (Deacon) on Oct 29, 2004 at 08:14 UTC
    if you just want to copy files you can set up public-key authentication, so you won't be prompted for a password.
    keep in mind that you can use scp just like cp but with a special syntax for remote files (like the rcp syntax).

      For those of you yet to experience the pure joy of SSH used properly:

      On a unix box: (or Cygwin).

      %> ssh-keygen -b 1024 -t RSA <key in a good passphrase twice>

      Now let's copy the Public key to the remote machine you want to have access to:

      cat .ssh/id_rsa.pub | ssh -l<user> <target_ip> '[ -d .ssh ] || mkdir . +ssh ; chmod 700 .ssh ; cat - >> ~/.ssh/authorized_keys'

      Now let's start up ssh-agent. You can either run you WM via ssh-agent: Add the following to your .xinitrc file:

      exec /usr/bin/ssh-agent <Window Manager of choice>

      or to your .bashrc:

      SSHAGENT=$(which ssh-agent) SSHAGENTARGS="-s" if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then eval `$SSHAGENT $SSHAGENTARGS` trap "kill $SSH_AGENT_PID" 0 fi

      Hooray... We're all set

      Now, run ssh-add to add your private key passphrase to the ssh-agent keyring:
      %>ssh-add <key in your passphrase>

      Now, you can log into the remote machine with wanton abandon.


      Repeat as necessary

      I hope you'll all forgive the non-perlness of this post but I thought someone, somewhere may just find it usefull.

      SM

        For bonus points, tell us how to do it on Windows, since that was the OS in question.

        C.

Re: SSH Help
by Anonymous Monk on Oct 29, 2004 at 06:24 UTC
Re: SSH Help
by bibo (Pilgrim) on Oct 29, 2004 at 14:53 UTC
    Well I have had fair luck with psftp which comes from the putty people. I am on Win2K, and you can provide a password on the command line with psftp, maybe this will help?

    --bibo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://403575]
Approved by dfaure
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 07:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found