Saturday, October 21, 2006

SFTP Scripting

SFTP has the expanded features of ftp, with the security of scp.
The typical ssh keygen and authorized_keys file are needed to set up a remote login without a password prompt. Configuring and testing login without password can be done with ssh or scp or sftp.

When sftp is able to log in without a password prompt, it is then time to create a batch file. The batch file contains sftp commands. In the batch file, a leading hyphen "-" instructs sftp to ignore an error.
$ cat sftp.batch
-rm /u001/testfile.Z
put /u001/testfile.Z
ls -l /u001/testfile.Z

The command is:
/bin/sftp -bsftp.batch ftpuser@ftphost

No comments:

Post a Comment