gpg --homedir change directory not working
Asked Answered
C

3

5

We have a Windows Server 2008 R2 server. We installed gpg4win and it works. We can create public and secret keys and decrypt messages for those that have our public key.

The issue

The gnu install defaulted to my user profile and we would like it to be under a generic one.

We created a directory c:\gpg_keys

According to the documentation on the gnu web site:

    gpg --homedir /my/path/ 
    to make GnuPG create all its files in that directory. " 
    When we run this command this is windows install: 
    gpg --homedir c:\gpg_keys\          the return is: 
    gpg: keyring `c://gpg_keys//secring.gpg' created 
    gpg: keyring `c://gpg_keys//pubring.gpg' created 
    gpg: Go ahead and type your message ...

Here the process stops.

When we look at the target directory we have:

    08/28/2013  05:14 PM                 0 pubring.gpg    
    08/28/2013  05:14 PM                 0 secring.gpg.lock 
    08/28/2013  05:14 PM                 0 pubring.gpg.lock 
    08/28/2013  05:14 PM                 0 secring.gpg 

4 files of zero length are created.

Is there any way to get the target directory for home moved?

Candor answered 29/8, 2013 at 4:54 Comment(1)
For the record, --homedir works fine in Linux (tested in Xubuntu 22.04.1). I know that's not what you're using.Highbinder
C
7

The --homedir apparently does not work but the following does:

Home directory:
  ===============
  GnuPG makes use of a per user home directory to store its keys as well
  as configuration files.  The default home directory is a directory
  named "gnupg" below the application data directory of the user.  This
  directory will be created if it does not exist.  Being only a default,
  it may be changed by setting the name of the home directory into the
  Registry under the key HKEY_CURRENT_USER\Software\GNU\GnuPG using the
  name "HomeDir".  If an environment variable "GNUPGHOME" exists, this
  even overrides the registry setting.  The command line option
  "--homedir" may be used to override all other settings of the home
  directory.

checking with --version shows the directory has been changed.

Candor answered 29/8, 2013 at 14:41 Comment(2)
Changing --homedir seems to mess up the key agent. It is a major bug in gpg4win, and it has been open for about two years now. I've submitted a bug report to their issue tracker: wald.intevation.org/tracker/… Let's home it gets some attention. I'd fix it myself, if I had the time and the slightest idea where to begin.Mavis
Setting the GNUPGHOME environment variable worked for me with GPG4Win 2.2.3. The --homedir option did not work.Tovatovar
M
2

The --homedir xxx option is just that - an option. It MODIFIES how some other command works.

As an example, if you have a directory /tmp/gpg containing keyring files and want to see what keys are in them, you might run something like this:

gpg --homedir /tmp/gpg --list-keys

In this example, --list-keys is the command, and --homedir /tmp/gpg is an option which modifies how that command works, i.e. what directory to look in for the keyring files.

When you ran gpg --homedir c:\gpg_keys\, you didn't supply a command at all, so gpg did exactly what it does if you had just run gpg by itself - tried to figure out what you wanted, based on the input it receives. It even told you that it wanted input, when it said this:

gpg: Go ahead and type your message ...
Macerate answered 8/7, 2022 at 1:11 Comment(2)
Except --homedir does work on Linux without specifying such as --list-keys before it. Are you sure that's the issue? Yeah, it'll tell you to 'Go ahead and type your message', but if you press Ctrl+c, and look, it'll have written the settings to the specified location. It's possible Windows is or a different version was different, there.Highbinder
It creates files under the --homedir directory if those files didn't already exist. The keyring files always start off as empty, and if the command you're running doesn't add any new keys, then the files will stay empty. The order of the arguments may or may not matter. The normal order for most OS's (other than windows) is "options first", which is why my example above has the --homedir option before the --list-keys command. I haven't used windows regularly in years (and don't have a windows machine to check now) but I seem to remember their convention is "options last".Macerate
M
1

Here's a ready made solution in the form of a .reg file. Paste this into example.reg, edit, save, then double-click on the resulting file.

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\GNU\GnuPG]
"HomeDir"="c:\\edit this\\.gnupg"
Mavis answered 22/12, 2014 at 0:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.