Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: GnuPG: users

Cannot import private key

 

 

GnuPG users RSS feed   Index | Next | Previous | View Threaded


mail at scott

Apr 18, 2012, 2:13 PM

Post #1 of 4 (1101 views)
Permalink
Cannot import private key

Hi everyone,

I am trying to integrate GnuPG with my workflow, and am in the stage of
setting up a new keypair for use across all of my computers. I have created
the key pair, given the private key a passphrase, and generated a
revocation certificate for that key. I am now trying to import that private
key on another computer, but I am having some issues.

I first export the private key using:

gpg --export-secret-key -a <key_id> > private.asc

This seems to work fine, and generates an ASCII-armored key file of the form

-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG v1.4.9 (MingW32)
[snip]
-----END PGP PRIVATE KEY BLOCK-----

I then take this private key file to a new computer and try to import it
using

gpg --import private.asc
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0

Any suggestions? This process works fine for exporting and importing public
keys, it's only the private one that is throwing this error. I have also
tried the --allow-secret-key-import, though I understand this is
effectively redundant now.

Regards,
-Scott


peter.c.dietrich at freenet

Apr 19, 2012, 3:39 AM

Post #2 of 4 (1068 views)
Permalink
Re: Cannot import private key [In reply to]

On Wed, 18 Apr 2012 23:13:27 +0200, Scott Armitage
<mail [at] scott> wrote:

> Hi everyone,
>
> I am trying to integrate GnuPG with my workflow, and am in the stage of
> setting up a new keypair for use across all of my computers. I have
> created
> the key pair, given the private key a passphrase, and generated a
> revocation certificate for that key. I am now trying to import that
> private
> key on another computer, but I am having some issues.
>
> I first export the private key using:
>
> gpg --export-secret-key -a <key_id> > private.asc
>
> This seems to work fine, and generates an ASCII-armored key file of the
> form
>
> -----BEGIN PGP PRIVATE KEY BLOCK-----
> Version: GnuPG v1.4.9 (MingW32)
> [snip]
> -----END PGP PRIVATE KEY BLOCK-----
>
> I then take this private key file to a new computer and try to import it
> using
>
> gpg --import private.asc
> gpg: no valid OpenPGP data found.
> gpg: Total number processed: 0
>
> Any suggestions? This process works fine for exporting and importing
> public
> keys, it's only the private one that is throwing this error. I have also
> tried the --allow-secret-key-import, though I understand this is
> effectively redundant now.
>
> Regards,
> -Scott


Dear Scott,

I think you should try to export the private key unarmored, i.e. leave out
the -a option. This should work.

Regards,
Peter

_______________________________________________
Gnupg-users mailing list
Gnupg-users [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-users


mail at scott

Apr 19, 2012, 5:38 AM

Post #3 of 4 (1072 views)
Permalink
Re: Cannot import private key [In reply to]

On Thu, 19 Apr 2012 12:39:22 +0200, Peter C. Dietrich
<peter.c.dietrich at freenet.de> wrote:
> On Wed, 18 Apr 2012 23:13:27 +0200, Scott Armitage <mail at scott.armitage.name> wrote:
>> gpg --export-secret-key -a <key_id> > private.asc
>>
> I think you should try to export the private key unarmored, i.e. leave out
> the -a option. This should work.

Thanks, Peter; I tried that, but couldn't get it to work either.

I think I have solved the problem though (I still need to try and
reproduce it from scratch, to verify my theory). It seems that
Powershell uses UCS-2 character encoding when using redirectors (the
">" in my commands). Changing the file encoding to ANSI or UTF-8
allows the private key to be imported properly. It is unclear to me
why the public key would import fine, however.

For the record, I was using redirectors instead of the "-o" option
because apparently it has no effect (at least in Powershell on
Windows) if you use it after the --export option. I have now figured
out that I can use "-ao <file.asc>" before the "--export-secret-key
<key_id>" and everything works fine:

gpg -ao private.asc --export-secret-key <key_id>
gpg --import private.asc
gpg: key <key_id>: already in secret keyring
gpg: Total number processed: 1
gpg: secret keys read: 1
gpg: secret keys unchanged: 1

Thanks for the help!
-S

_______________________________________________
Gnupg-users mailing list
Gnupg-users [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-users


dougb at dougbarton

Apr 19, 2012, 1:10 PM

Post #4 of 4 (1062 views)
Permalink
Re: Cannot import private key [In reply to]

On 4/18/2012 2:13 PM, Scott Armitage wrote:
> I am now trying to import that private key on another computer, but I am
> having some issues.

Try just copying the files. IME it's almost never necessary to do the
export -> import dance. If a plain copy doesn't work, then try the
suggestion to do the export without -a.

Doug

--
If you're never wrong, you're not trying hard enough

_______________________________________________
Gnupg-users mailing list
Gnupg-users [at] gnupg
http://lists.gnupg.org/mailman/listinfo/gnupg-users

GnuPG users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.