Migrate from FTP to SFTP

Hi,I am using following code for FTP in shell script file and it is working.Now I want to migrate from FTP to SFTP.What code changes/steps I have to perform for SFTP ?

ftp -in <<FIN
open $SAP_UP_SERVER
user $SAP_UP_USER $SAP_UP_PASSWORD
asc

  put $PM00\_OUTPUTS\_DIRECTORY/$SAP\_UP\_FILE_CSV /$SAP\_UP\_FILE_CSV
  put $PM00\_OUTPUTS\_DIRECTORY/$SAP\_UP\_FILE_CTL /$SAP\_UP\_FILE_CTL
  prompt ... End File ftp dates transaction

If you are migrating from FTP to SFTP then I strongly suggest to setup ssh password-less login to avoid using hard-coded passwords.

Syntax is same for SFTP

sftp user@hostname << EOF
put file1
put file2
EOF

My shell scripts are executing on Unix server and transfering files to window server 2008.Will your article work in this scenario ? If yes, then which approach will I have to take from the article ? (1) Getting Started (2)Using X Windows (3)Different usernames
(4)More keys! (5) Single-purpose keys

Never tried SFTP from UNIX to Windows myself. But I found there are several options available to get this done. OpenSSH under Cygwin is one option. I also found CompleteFTP supports public-key authentication (RSA and DSA).

it is not an one time activity.Control-M job is executing shell scripts everyday, so what option will be better ?

If you have several users running Control-M job to execute shell scripts then I guess you have to setup keys for each one of them (More Keys!). I suggest you to isolate the file transfer task under one user if possible so that you can avoid this tedious task of setting up keys for several users.

There are not several users running Control-M job to execute shell scripts.There is one scheduled job (via Control-M) on server that is executing shellscript everyday.

so how to setup ssh password less login to avoid using hard-coded passwords ? Can you please give me detailed steps ?

Here is a guide on OpenSSH RSA authentication from Linux to Windows and Windows to Linux. I hope this helps.