Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

PGP - Encrypt and decrypt files through batch Expand / Collapse
Author
Message
Posted Wednesday, July 9, 2008 11:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 10, 2008 9:41 AM
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
Post #531115
Posted Wednesday, July 9, 2008 12:53 PM
UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Friday, April 5, 2013 4:43 PM
Points: 1,473, Visits: 1,314
Where did you fire your command? Did you set the environmental variable?
Post #531166
Posted Wednesday, July 9, 2008 1:05 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 10, 2008 9:41 AM
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
Post #531176
Posted Wednesday, July 9, 2008 6:23 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 1,046, Visits: 2,737
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, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #531306
Posted Thursday, July 10, 2008 8:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, July 10, 2008 9:41 AM
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
Post #531689
Posted Thursday, July 10, 2008 9:01 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 1,046, Visits: 2,737
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, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #531704
Posted Tuesday, May 17, 2011 9:19 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 21, 2014 12:49 PM
Points: 5, Visits: 68
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......
Post #1110701
Posted Wednesday, May 18, 2011 7:18 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 1,046, Visits: 2,737
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, SQL Server MVP
Independent Business Intelligence Consultant
www.TimMitchell.net
@Tim_Mitchell

Post #1110943
Posted Wednesday, May 18, 2011 3:49 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 21, 2014 12:49 PM
Points: 5, Visits: 68
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
Post #1111379
Posted Wednesday, May 18, 2011 7:18 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 11:51 PM
Points: 15, Visits: 696
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



Post #1111447
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse