Operating System - HP-UX
1834154 Members
2524 Online
110064 Solutions
New Discussion

Re: Secure FTP thru batch job

 
Clement_7
Occasional Advisor

Secure FTP thru batch job

Hi All, would like to find out if it is possible to run secure ftp thru cronjob or atjob. If yes, how to do it?
6 REPLIES 6
Steven E. Protter
Exalted Contributor

Re: Secure FTP thru batch job

If you are talking about Secure Shell SFTP, its pretty easy.

First:
Exchange public keys.
See attached doc
works for any user

Then batch jobs can do scp sftp and ssh secure as heck.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Mauro Gatti
Valued Contributor

Re: Secure FTP thru batch job

You can put commands you want to do during sftp session into a file and next you can call sftp using "-b" option followed by file with command to do.
For exemple if you want set soruce and destianztion directory and you want to erase old file and "rotate" it before upload you can put in yur script file:
lcd /source
cd /destination
rm old.file
rename new.file old.file
put -P new.file
quit

and next you have to call sftp like:

sftp -b script.txt your_server

Be sure to exchange ssh keys as Steven Protter explained before run sftp via crontab.

I Hope this help you.
RGDS


Mauro
Ubi maior, minor cessat!
Clement_7
Occasional Advisor

Re: Secure FTP thru batch job

how do I include the user password in the secure ftp batch job?
Geoff Wild
Honored Contributor

Re: Secure FTP thru batch job

You have to use "expect" scripts to do this...

http://hpux.ee.ualberta.ca/hppd/hpux/Tcl/expect-5.41/

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Mauro Gatti
Valued Contributor

Re: Secure FTP thru batch job

If you use ssh keys authorization you don't need to put password into script.
User can be set using this notation:
sftp -b batch.file user@destination.host

RGDS

Mauro

Ubi maior, minor cessat!
walsemge
New Member

Re: Secure FTP thru batch job

Why don't you use scp if yo want to increase securety. Adding a password in a script is one thing I wouldm't do.
Use scp and add your public key in the the user@server:~/.ssh/authorized_keys file of the user.
This way you can send files without adding a password in your script.

Greetings,
Wim