1753835 Members
7705 Online
108806 Solutions
New Discussion юеВ

sftp automated script

 
Links Moodley
Advisor

sftp automated script

What is the syntax in HP Ux script to invoke sftp using the open command? my script looks like this
open nashualocal
user FTPUser N@shua!
type ascii
cd Nashua/New_Orders
lcd /usr1/EMBRACE/EMBRACE.LIVE/NASHUA.SALES
mget *.csv
lcd /usr1/EMBRACE/EMBRACE.LIVE/NASHUA.SALES.BACKUP
mget *.csv
cd /Nashua/New_Orders
pwd
!uuencode /usr/bin/nash1.log nash1.log.csv | mailx -m -s "Nashua Confirmation" l
moodley@tarsus.co.za hdebloe@tarsus.co.za ebrown@tarsus.co.za
quit
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor

Re: sftp automated script

Hi:

Setup public ssh keys between your servers. Then you can do something like:

# cat .mysftp
HOST=$1
FILE=$2
sftp -b - <lcd /tmp
cd /tmp
put -P ${FILE} ${FILE}.backup
EOF
RC=$?
print -u2 "\nSFTP returned ${RC}"
exit ${RC}

Regards!

...JRF...
Links Moodley
Advisor

Re: sftp automated script

Thank You for that James, excuse my ingnorance, how do I setup up the public ssh keys on my server and the external server.
Regards,
Links
James R. Ferguson
Acclaimed Contributor

Re: sftp automated script

Hi (again):

You can and should avoid passwords in scripts if you are automating Secure Shell functions like 'scp', 'sftp', etc. Public keys provide the methodology.

Matti Kurkela gives a quick-step view here:

http://h30499.www3.hp.com/t5/System-Administration/sample-script-for-scp-and-sftp/m-p/4243294#M330281


...and Doug O'Leary provides a detailed guide here:

http://www.olearycomputers.com/ll/ssh_guide.html

The 'known_hosts' file contains the public host keys for all known hosts. The per-user version is maintained automatically. Thus, whenever you connect from an unknown host, its key is added to the per-user file if you choose to acknowledge the fingerprint. If you don't, the connection can still be made, but you will be prompted the next time as if you had never connected.

The manpages for 'sshd' and 'ssh' offer more information.

Regards!

...JRF...