Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


PGP - Encrypt and decrypt files through batch


PGP - Encrypt and decrypt files through batch

Author
Message
awelsh
awelsh
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 5
I just installed PGP software on my machine. Now I want to use it, but not in the GUI interface provided. I'd like to type something like [pgp -s testpgp.txt] at a DOS prompt and have the file either encrypt or decrypt. I'm not able to find the exact command. Also, at the command line, it is giving me an error stating it cannot locate pgp.

Can anyone help me assign or direct me to the write syntax to accomplish this?

Thanks,
Amy Welsh
awelsh@welshkc.com
SQL ORACLE
SQL ORACLE
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1487 Visits: 1314
Where did you fire your command? Did you set the environmental variable?
awelsh
awelsh
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 5
I opened a command Prompt window and typed pgp -s filename.txt. No, I didn't set up the environment, which is why I suspect it is erroring stating it doesn't understand what pgp means.

My company purchased PGP Desktop software that I should use to encrypt the data going between the client and I. I've used PGP before, and did it at the command line instead of through the GUI interface. I wanted to do that again.

The PGP software is at c:\Program Files\PGP Corporation\PGP Desktop\PGPdesk.exe. But within this software, there are many options. I want the Zip function, and from the command line I'm not sure how to tell it what I expect.

Any suggestions? I'm beginning to think the free pgp version would be easier to use in this fashion than PGP Desktop.

Amy
Tim Mitchell
Tim Mitchell
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 2908
awelsh (7/9/2008)
I opened a command Prompt window and typed pgp -s filename.txt. No, I didn't set up the environment, which is why I suspect it is erroring stating it doesn't understand what pgp means.

My company purchased PGP Desktop software that I should use to encrypt the data going between the client and I. I've used PGP before, and did it at the command line instead of through the GUI interface. I wanted to do that again.

The PGP software is at c:\Program Files\PGP Corporation\PGP Desktop\PGPdesk.exe. But within this software, there are many options. I want the Zip function, and from the command line I'm not sure how to tell it what I expect.

Any suggestions? I'm beginning to think the free pgp version would be easier to use in this fashion than PGP Desktop.

Amy


Amy, it appears that you have two different issues - first, you're calling PGP.exe but your environment doesn't know where to find this file, and second, you're not able to use the command line options you want.

For the first issue, you either need to set the environmental variable as the first respondent suggested, or use the full path to call PGP.exe (rather than just calling it by file name). I recommend the latter, particularly if you plan on moving your package from one machine to another.

The second issue is not really an SSIS issue but a PGP issue. I've used PGP a couple of times in SSIS packages but I can't tell you exactly what the command line parameters are. From the command line, enter the path to the PGP executable and use the Help parameter, which will normally be /? or -help. The output should explain file usage.

Hope this helps...
Tim



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


awelsh
awelsh
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 5
Thanks Tim. That gets me farther.

I haven't figured out the parameters to pass yet. Each time I type the executable name, the software interface pops up instead of giving me a list of help topics that I'd prefer.

I'll keep playing around with it.

Thanks again for the response!

Amy
Tim Mitchell
Tim Mitchell
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 2908
Amy, if you're entering the executable name and the graphical tool is coming up, you're calling the wrong executable. There will be a different EXE file for command-line usage. In the version that I have used (which is an older version), the command line executable was pgp.exe.

Hope this helps...
Tim



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


litsonjose 5315
litsonjose 5315
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 83
Hello Tim,

My problem is in decryption part.
I have set the pgp environment, passed the arguments, set the working folder. When i run the SSIS package from development environment , the decryption process is running perfectly. But, when i try to call the same SSIS package from a stored procedure (SQL SERVER) , I am getting an error and the file is not decrypting. I am sure my batch file is executing because before the decrypt command i am deleting an exsisitng file. Only problem is in this command

echo *******| gpg --passphrase-fd 0 --decrypt-files "\Files_Import\FTP\%1.txt.pgp"

The error msg is "The process exit code was "2" while the expected was "0"."

waiting for the reply......
Tim Mitchell
Tim Mitchell
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1122 Visits: 2908
litsonjose,

I've not used the GPG tool specifically - when I need command line en/decryption, I've used PGP in the past. However, on the PGP command line there is a text prompt that you must confirm the first time you use the executable, and this must be done at the user level (a prompt to add the key to the cache, if I'm not mistaken). There was a "silent mode" that would suppress this prompt and continue execution.

Since the command line app works under your login but not as a scheduled job, I suspect that your problem is probably similar to what I found with PGP. Look in the GPG product documentation or help commands to see if there is a silent mode to suppress prompts. Alternatively, you might log into the server as the account that executes the job and try to run the command line app manually - you may be able to override the prompt there.

hth,
Tim



Tim Mitchell, Microsoft Data Platform MVP
Data Warehouse and ETL Consultant
TimMitchell.net | @Tim_Mitchell | Tyleris.com
ETL Best Practices


litsonjose 5315
litsonjose 5315
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 83
Hello Tim,,

Is that error any thing related to the permission of sql server ? I created an Sql job which executed the batch file. The batch file has the code to decrypt the gpg file . Below is the code

echo test| gpg --passphrase-fd 0 --decrypt files "F:\folder\FTP\DL-8153015-20110518.txt.pgp"

"test" is the passphase.

When i execute this batch file from sql server agent , i am getting this error log :

C:\Windows\system32> echo test| gpg --passphrase-fd 0 --decrypt files "F:\folder\FTP\DL-8153015-20110518.txt.pgp"
gpg: encrypted with ELG-E key, ID 2AADDF95
gpg: decryption failed: secret key not available

Why it saying secret key not available. the "test" is the secret key and this same command run perfectly in command prompt. Why not in sqlserver agent or from sql sp's...

I think its some thing to do with permission level in sql server. Because the decrypt uses the private key and need full system environment... What's your solution.. Can you advice.. I am stuck up with this issue for 2 days....My system is 64bit , os is vista. GnuPG - The GNU Privacy Guard Version 1.4.11
Peter Lavelle-397610
Peter Lavelle-397610
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 742
Hi Amy,

You could try this to redirect display to nowhere:

gpg --<your gpg parameters> > nul

or to a file:

gpg --<your gpg parameters> > path\filename
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search