Technical Note 2126
Last Reviewed 05-Mar-2015
Reflection for Secure IT Windows Client version 7.0 or higher
Reflection for Secure IT UNIX Client version 7.0 or higher
Both the scp (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 sftp 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.
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 command.
Commands Available in Reflection for Secure IT
A full list of commands and their syntax can be viewed either from your product's documentation page online or from the sftp client itself.
To access a list of commands for the Windows client online, see http://docs.attachmate.com/reflection/rsit-ssh/7.2sp3/winclient/help/en/rsit_client_sftp_command_rf.htm.
To access a list of commands from Reflection for Secure IT Windows Client, follow these steps:
- Establish an sftp connection to a host.
- At the host prompt, enter help.
A list of supported commands and definitions will be displayed.
To access a list of commands for the UNIX client online, see http://docs.attachmate.com/reflection/rsit-ssh/8.0sp1/unix/en/man-pages/sftp_man_page.htm.
To access a list of commands from Reflection for Secure IT UNIX Client, follow these steps:
- At the client host prompt, before connecting to a host, enter sftp.
- At the sftp prompt, type help.
A list of supported commands will be displayed. Note: To obtain detailed information about a command, type help <command name>.
Sample Batch Files
The following sample batch files upload a file in binary mode to the user's .ssh2 directory, and then disconnect:
3. Use the SFTP Command to Authenticate and Run the File
Use the following command to authenticate to your host and run the file transfer batch file.
Syntax: sftp B <path>\<batch_file> <username>@<hostname>
Example: sftp B C:\MyFiles\uploadkey.txt user1@myhost
Syntax: sftp B /<path>/<batch_file> <user name>@<host name>
Example: sftp 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 sftp command line in the Windows batch file.