APM: scp with perl
ian at remmler.org
Fri Jul 23 09:34:13 CDT 2004
On Fri, Jul 23, 2004 at 09:45:49AM -0400, Moon, John wrote:
> Have multiple Unix platforms that I need to pickup files from then delete on
> each respective platform once picked and processed. I was using ftp put they
> are starting to shut down that option. Any suggestions of another approach
> will be greatly appreciated.
> I have tried to use system(" scp ... ") but keep getting a request for a
To get around the password thing, you can have scp (ssh) use
public key crypto to authenticate instead. Just generate an ssh
key on each machine you need to scp files from:
> ssh hostname
... enter password ...
> ssh-keygen -t rsa
Then, get the file ~/.ssh/id_rsa.pub from each of those machines
and append its contents to the file ~/.ssh/authorized_keys on
the machine you'll run the script from.
> scp hostname:.ssh/id_rsa.pub /tmp/id_rsa.pub.hostname
Or some such, for each host. Then:
> cat /tmp/id_rsa.pub.* >> ~/.ssh/authorized_keys
You should now be able to ssh/scp without needing a password.
If you already knew all this, well, maybe someone somewhere
learned something at least. :)
On the Perl side, a quick look at http://search.cpan.org reveals
Net::SCP, which will probably do what you need.
Ian Remmler | A monk asked Joshu, "Has a dog Buddha
ian at remmler.org | nature or not?" Joshu replied, "Mu!"
http://remmler.org | -- Mumon, "The Gateless Gate"
More information about the Austin