Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to run use the gpg tool to encrypt and decrypt files and I would like to know if it's possible to run this tool without it changing a user's global state. Specifically, running gpg for the first time as a given user will cause it to create a .gnupg directory and other artifact's in a user's home directory.

I've had some success in isolating the operation of this command from a user's public and secret key ring (see my Ruby gem at https://github.com/rcook/rgpg for how I do this) and this is the last remaining behaviour of gpg I'd like to prevent.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can pass it the --homedir argument or use the GNUPGHOME environment variable to have it use another directory instead of .gnupg. If you're scripting this, you could create a temporary directory:

GNUPGHOME=$(mktemp -d $HOME/.gnupgXXXXXX)
export GNUPGHOME

And then clean up when you're done:

gpg ...
rm -rfi $GNUPGHOME
share|improve this answer
    
Perfect! Thanks. –  Richard Cook Aug 2 '13 at 20:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.