Technical Notes |
|
The secure shell protocol allows for Secure FTP (SFTP) transfers. This technical note discusses three ways to automate SFTP transfers: using a Reflection FTP client script, programming with the Reflection FTP API, or by running command line ssh utilities.
Note: For information about automating SFTP file transfers using Reflection for Secure IT, see Technical Note 2126.
The OpenSSH protocol 2 draft standard includes the Secure FTP (SFTP) protocol for file transfer. SFTP supports fewer commands than the full FTP protocol, but allows all commands and data to be sent through a single, secure channel. This means that all of your communications are encrypted.
You will also need to enable the SFTP subsystem in the host’s sshd configuration file (usually named sshd_config). To verify that this is enabled, view or print the sshd daemon configuration file and look for a line similar to the following:
Subsystem sftp /usr/local/libexec/sftp-serverIf the SFTP subsystem is not enabled, refer to the host's documentation for information about enabling the subsystem.
Reflection supports automating SFTP transfers using three methods:
Note: Beginning in Reflection 13.0, the SSH connection is called Secure Shell. Earlier Reflection versions called the SSH connection OpenSSH.
Historically, SFTP clients and servers do not support wildcards, or MGET or MPUT commands, which facilitate multiple-file transfers. However, you may be able to overcome these limitations, depending on which method you use.
To automate SFTP transfers with the Reflection FTP Client, three steps must be performed:
You can create a new SFTP site or configure an existing FTP site to use SFTP. Follow the steps in the appropriate section below.
To create a new SFTP site that the Reflection FTP Client can connect to using Reflection Secure Shell client, follow these steps:
A key and/or padlock icon appears on the status bar when you have made a successful secure connection. The key indicates secure authentication; the padlock indicates an encrypted data stream.
You can configure an existing FTP site to use SFTP by following the steps below:
A key and/or padlock icon appears on the status bar when you have made a successful secure connection. The key indicates secure authentication; the padlock indicates an encrypted data stream.
Once the FTP site is configured to use SFTP, you must automate the authentication process before you can automate secure file transfers. SSH requires a password unless another secure authentication is used.
To automate authentication, use either User Key Authentication or Kerberos key exchange.
User key authentication relies on a public/private key pair that is used for authentication purposes. Before you can make SSH connections to hosts this way, both your PC and the host must be correctly configured.
For Reflection 11.0 12.x: Click the OpenSSH tab and click Configure to open the Reflection OpenSSH Client Settings dialog box.
For Reflection 11.0 12.x: In the Authentication group box, select User key. (This is the default setting.)
For Reflection 11.0 12.x: Click Generate Key.
For Reflection 11.0 12.x: Click OK.
There will be a pause before you see dialog box to specify a file name for your keys. During this time your key is being generated. The length of the wait depends on the key type and key length you have specified.
Reflection suggests standard names for your key files depending on the key type you specified. A public key is created using this name with a *.pub extension. The corresponding private key uses the same name with no extension.
Click Save to continue.
Click OK to complete the process.
(Host configuration may be done by the administrator of the host.)
Add the public key created for the PC to the authorized key file in the user's home directory: $HOME/.ssh/authorized_keys.
Note: You may see an SSH banner from your server displayed in a message box that requires you to click OK to continue, thereby disrupting the automated processing. To prevent this message box from displaying, go to Site Properties > Security Tab > SSH Tab > Configure Button > Logging and set logging level to Quiet.
For further details, see Technical Note 1881.
When Kerberos key exchange is selected, the Reflection Secure Shell client uses Kerberos for authentication. You must have the Reflection Kerberos Client installed and configured to use this feature; the key exchange setting is dimmed if the Kerberos Client is not installed.
Notes
For Reflection 10.x - 12.x: Click Security.
Note: Unless your PC has a Kerberos configuration file installed, you'll see the Initial Configuration dialog box the first time you use Reflection Kerberos. You must specify default Kerberos settings in this dialog box before you can make a connection. Use the dialog box help for more information.
For Reflection 11.0 12.x: In the Authentication group box, select Kerberos key exchange.
Reflection FTP Client will save this configuration and automatically use Kerberos authentication the next time you connect to this server.
Once you have successfully configured the Reflection FTP Client to automatically connect to an SFTP server, you can automate file transfers using the Script Recorder.
You can run your script from the command line in a BAT file, Windows Shortcut, scheduler program, or shell command.
<path>RFTPC.EXE "<FTPSiteName>" /RFS "<path>\Script.rfs" /L "<path>\Log.log"The following command would start Reflection FTP Client from its default location, connect to the FTP Site named "MySFTPSite," run the script SFTPScript.rfs, and create a log file C:\Temp\SFTPLog.log:
"C:\Program Files\Reflection\rftpc.exe" "MySFTPSite" /RFS "C:\Program Files\Reflection\User\SFTPScript.rfs" /L "C:\Temp\SFTPLog.log"Another method of automating SFTP transfers is to create VBA macros in Reflection for HP, Reflection for IBM, Reflection for UNIX and OpenVMS, Microsoft Office, or in any development environment that supports the OLE or COM interface to programming.
An example that uses VBA to create a filter for file extensions is available for you to review. The macro will transfer all files in a given directory that match the strFilter variable.
To explore this approach, download the sample file and import it to a VB or VBA editor:
Using VBA, you can add features to your macro, such as checking to see if files exist before attempting a transfer, deleting files when you are done, writing error logs, or emailing system administrators if a critical file transfer fails.
For information about running sftp.exe on a command line to automate a secure file transfer, see Technical Note 2126.