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

Automatic scp

by Anonymous Monk
on Jun 05, 2000 at 00:25 UTC ( [id://16325]=perlquestion: print w/replies, xml ) Need Help??

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

Is there any way to use secure copy within perl and have perl give the necessary passwords? I guess there must, but I just cannot figure out how to do it.

Replies are listed 'Best First'.
Re: Automatic scp
by Corion (Patriarch) on Jun 05, 2000 at 00:45 UTC

    From looking at the scp and the ssh man pages - you get it via your shell by typing man 1 scp there is the hint that the -f option does not ask for passwords (and also leaves no ssh window open). scp has the -o command line option that allows to deliver options to ssh. So you have to try that. If you don't have success with that, you could try either open scp for writing and try to write the password to scp, but I've never done this myself. The thing I'd try would be

    open SCP, "| scp -o -l $filename $user\@$host:$target"; print SCP, $password; # now pray that scp does its magic ...
      A quick test with OpenSSH shows this to work, using
      scp -B $file $user\@$host:$target
      The -B on OpenSSH is equiv to your -f
Re: Automatic scp
by mdillon (Priest) on Jun 05, 2000 at 00:35 UTC
    this is not Perl-specific, but i would just set up your installation to use public-key based authentication instead of password authentication.

    then, you can either set a null passphrase on your private key and trust OS level security to keep your key private, or use the authentication agent (ssh-agent) and enter your passphrase before invoking the Perl utility that uses SCP.

    you may be able to use Expect.pm to do password based SCP, but it's probably way more trouble than it's worth (at least according to me).

Re: Automatic scp
by schumi (Hermit) on Dec 03, 2002 at 10:23 UTC
    Well, for this Anonymous Monk it's probably way too late, but for anyone else who is searching and finding this post - like I just did. Here goes:

    Try this: Net::SCP

    --cs

    There are nights when the wolves are silent and only the moon howls. - George Carlin

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found