I recently had to help a client with encrypting a file before uploading that file to an FTP. Thanks to the PGP task in Task Factory we were able to fulfill this requirement in a matter of minutes.
In this example I will walk you through quickly creating public and private keys and then using those keys to encrypt the file.
- Create two variables. One for the source location and one for the destination:
- From the SSIS Toolbox drag and drop the PGP Task into the control flow and then open it for editing.
- For “What action will this perform?” choose Encrypt File.
- Click Generate Key to create your own public and private keys. Note: Public keys are used for encryption and private keys are used for decryption.
- Now to fill out some basic information. The private key created will require a password, please remember to store this password somewhere safe, i.e. some kind of password vault. This will be required to decrypt files.
- Now that we have generated PGP keys we can now encrypt our files in just a couple steps. A screenshot of all steps below is listed at the bottom.
- For Section 1:
- Select “File location is stored in a variable”
- Select “strFileName” for the variable
- Section 2:
- Select “Destination location is stored in a variable”
- Select “strFileName_Encrypt” for the variable.
- Select the checkbox for Overwrite the destination file if it already exists
- Section 3:
- Select connection manager: Select “Public”.
- Note: The connection manager “Public” was added to the package automatically when we generated new keys. Public is the name I gave to my public key ring.
- Finally select the Public Key you wish to use for encryption. We only have one key on our key ring.
I have provided three screenshots below.
- Screenshot 1 – Final Configuration
- Screenshot 2 – File before PGP Encryption
- Screenshot 3 – File after PGP Encryption
Screenshot of final configuration:
As always thanks for looking and your feedback is appreciated!