Windows – Using the GNUPG Encrypt Command on Windows 7 Professional

gnupggpg4winpgpwindows 7

I am using the Windows port of GNU Privacy Guard
"light" release for version 1.0.9 installed on a windows 7 professional laptop. Installed in the default directory of : C:\Program Files (x86)\GNU\GnuPG . The trustdb and keyring files are here: C:\users\\AppData\Roaming\gnupg. Both of these folders are pathed in my environment variable PATH.

I have been following along using this tutorial: http://www.glump.net/howto/gpg_intro

and everything has worked smoothly up to 4.1 Using the GPG Encrypt Command

When i try this command to encrypt a simple text file with one line "This is a Test!", i get an error.

gpg –recipient "John Doe" –output "C:\data.txt.gpg" –encrypt "data.txt"

The error i receive is:

gpg: can't open 'data.txt': no error
gpg: data.txt: encryption failed: file open error

Any ideas why i get this error? Anything do do with Win 7 rights? I checked the text files attributes and they are fine.

Does anyone know what folder the file will be created in? And, whether or not the folder needs special rights? As I stated above, i was able to do all the previous steps in the tutorial without an errors or issues…..including creating key pairs, and publishing a public key to file.

Thanks for any help you might be able to give me

Best Answer

I cannot explain the error message; however, it might just go away after upgrading to the latest GnuPG (install using Gpg4Win bundle).

The rest:


Does anyone know what folder the file will be created in?

The one you specified in --output, of course. C:\data.txt.gpg means the file will be in C:\, or directly in the root of the C: drive.

If you hadn't specified a path, only the name (for example, --output data.txt.gpg), the file would go to the "current directory", which is shown in the console window's "prompt". For example, the following happens in the F:\Users\Mantas directory, and later changes to C:\WINDOWS:

F:\Users\Mantas> gpg --recipient grawity --output data.gpg --encrypt data.txt
F:\Users\Mantas> cd /d C:\WINDOWS
C:\WINDOWS> _

After writing this, I realized that I may be able to explain the error message. In your question, you haven't actually mentioned whether you are in the correct directory or not. It could just be that your data.txt is elsewhere... although it'd make this a weird error message. Still, check using dir.


And, whether or not the folder needs special rights?

Nothing "special", but you do need the permission to create new files in that folder.

sually users are limited to their own "profile" folders under C:\Users, and creating files directly in C:\ may require elevation.