Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Automating SFTP File Transfers with Reflection for Secure IT
Technical Note 2126
Last Reviewed 29-Mar-2007
Applies To
Reflection for Secure IT Windows Client version 6.1 or higher
Reflection for Secure IT UNIX Client version 6.1 or higher
Summary

Both the scp2 (secure copy) and sftp (secure FTP) file transfer client utilities provide secure encrypted authentication and data transfer over SSH2. This technical note describes how to establish an authentication method that can be automated, how to create a batch file of sftp file transfer commands, and then how to issue an sftp2 command that uses the authentication method and batch file as parameters.

For more information about:

  • the difference between scp and sftp, see Technical Note 1918.
  • using the API to automate secure FTP transfer over SSH using the Reflection FTP Client, see Technical Note 1101.

1. Establish an Authentication Method that can be Automated

To automate file transfers, you must first set up an authentication method that does not require user input, such as Public Key Authentication with an empty passphrase.

For detailed steps on configuring Reflection for Secure IT for public key authentication, see Technical Notes 1926 and 1881.

2. Create a Batch File of SFTP Commands

Use a text editor, such as Notepad or vi, to create a text batch file that contains the sftp file transfer commands you want to automate. You will call this file when you issue the sftp(2) command.

Commands Available in Reflection for Secure IT

For a full list of commands and their syntax, follow the steps below, see "using sftp2" in the Reflection for Secure IT help, or consult the man pages for sftp2 (man sftp2).

Windows Client:

  1. Establish an sftp connection to a host.
  2. At the host prompt, enter help.

A list of supported commands and definitions will be displayed.

UNIX Client:

  1. At the client host prompt, before connecting to a host, enter sftp.
  2. At the sftp prompt, enter help.

A list of supported commands will be displayed.

  1. To obtain detailed information about a command, enter help <command name>.

The following sample batch file uploads a file in binary mode to the user's .ssh2 directory, and then disconnect.

##upload a public key from windows system to UNIX system.
lcd "C:\Documents and Settings\user1\My 
Documents\Attachmate\Reflection\.ssh"
cd /home/user1/.ssh2
binary
put user1.pub
quit
##upload a public key from UNIX system to UNIX system
lcd /home/user2/.ssh2
cd /home/user2/.ssh2
binary
put user2.pub
quit

3. Use the SFTP2 Command to Authenticate and Run the File

Use the following command to authenticate to your host and run the file transfer batch file.

Windows Client

Syntax: sftp2 –B <path>\<batch_file> <username>@<hostname>

Example: sftp2 –B C:\MyFiles\hostcopy.txt SReynolds@myhost

UNIX Client

Syntax: sftp2 –B /<path>/batch)file <user name>@<host name>

Example: sftp2 –B /home/user2//uploadkey_user2@myhost

Note: The –B parameter is case sensitive and is capitalized.

If you plan to automate further processes using a Windows batch file, you can include this sftp2 command line in the Windows batch file.

Related Technical Notes
1101 Automating Secure FTP (SFTP) Transfers over SSH
1881 Configuring Reflection for User Key Authentication
1918 The Relationship Between File Transfer, SSH, SCP2 (scp), and SFTP
1926 Public Key Authentication for Reflection or F-Secure SSH UNIX Client and Server for UNIX or Windows
1927 Public Key Authentication for UNIX OpenSSH Client and Reflection SSH Server for Windows or UNIX

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.