to copy files unix to unix automaticlly you will need to do the following

1:  setup public key exchange for the user you will run the cron script as
1a: type ~>/usr/local/bin/ssh-keygen2 -P
1b: you should get

~>/usr/local/bin/ssh-keygen2 -P
Generating 1024-bit dsa key pair
   8 .oOoo.oOo.oO
Key generated.
1024-bit dsa, alx@HELIOS, Fri Oct 27 2000 16:02:44 -0700
Key is stored with NULL passphrase.
Private key saved to /home/alx/.ssh2/id_dsa_1024_a
Public key saved to /home/alx/.ssh2/id_dsa_1024_a.pub

1c: type /usr/local/bin/ssh2 -l user server.ip.address
1d: type cd ~/.ssh2
1e: type ~>echo Key id_dsa_1024_a.pub >authorization
1f: type exit
1g: type ~>echo IdKey id_dsa_1024_a >identification
1h: type /usr/local/bin/scp2 /home/alx/.ssh2/id_dsa_1024_a.pub
[EMAIL PROTECTED]:/home/alx/.ssh2/id_dsa_1024_a.pub
2: write script to copy your files (use my test script below as an example)

here is the contents of my test cron script : /test/crontest

/usr/local/bin/scp2 -B /test/files2*  [EMAIL PROTECTED]:/test/crontest/
2>/var/log/testerror.log


contents of /etc/crontab:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
MAILTO=root
HOME=/root/

# run-parts
01 * * * * root run-parts /etc/cron.hourly
02 4 * * * root run-parts /etc/cron.daily
22 4 * * 0 root run-parts /etc/cron.weekly
42 4 1 * * root run-parts /etc/cron.monthly
23 * * * * alx /test/cron






/usr/local/bin/scp2 -B /test/files2* [EMAIL PROTECTED]:/test/crontest/
2>/var/log/testerror.log

/usr/local/bin/scp2  = location of scp2 command

-B     = option to start scp2 in Batch Mode

/test/files2*   = source files  (copy all files starting with files2)
      for my tests there are 5 files about 1 MB each
alx    = user cron will login to server as

@    = tells cron the following is the server

192.168.13.127   = ssh server (ether IP address or FQDN)

:    = tell's cron the following is the file

/test/crontest/   = location on server files will be placed

2>    = redirect error msg's to...

/var/log/testerror.log  = location and file name of where all error msg's





----- Original Message -----
From: Duncan Hill <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, December 02, 2000 3:34 PM
Subject: Automating file copies


>
> Greetings,
>
> I'm in a situation where I need to copy files from one host to another
> via a cron job.  Automated FTP is out, due to the need for the
> communication to be encrypted.  Is it possible to automate scp or sftp
> to do this?  The only problem I can see so far is having to spec the
> password somehow, and I'd rather not have a password or passphrase
> stored in a file..
>
>

Reply via email to