Following is the script that can be used to upload a file to a secure ftp (SFTP) when there is a limitation of sharing ssh keys and it is okay to pass the password in the script. With above in mind additional package SSHPASS needs to be installed. SSHPASS is in the Fedora repo however it can be installed on CentOS 5.x x86_64:
1 2 3
Once everything is OK following script can be used:
1 2 3 4 5 6 7 8 9 10 11 12 13
As I only wanted to initiate the connection when there is file in the folder so I kept it under the if loop. This script can be setup in the cron job to run every 60sec which was my req at that time.