Mailing List Archive

Problems when importing previously exported private keys on new linux system.
Hi there.

I am switching my linux release.
Before I reinstall the system, I use commands below to export my gpg keys.

vvvvvvvvvvvvvvvv
gpg --export-private-keys $key_id > private.key
gpg --armor --export $key_id > public.key
^^^^^^^^^^^^^^^

As expected, a window prompt requesting passwords to decrypt my private key, and both public key and private key file appeared in the explorer.
Then I move keys to my portable drive and reinstall system.

After the installation finished, I started to import keys exported minutes before.
The public key, as expected, imported successfully.
But problems occured when I was trying to import my private key.

vvvvvvvvvvvvvvvv
> gpg --import private.key
gpg: [don't know]: partial length invalid for packet type 63
gpg: read_block: read error: Invalid packet
gpg: import from 'private.key' failed: Invalid keyring
gpg: Total number processed: 0
> file private.key
private.key: data
^^^^^^^^^^^^^^^

So, here is the problem.
Is there any method to restore my private key or revoke it?
Why gpg program can't identify my key file? Is the root cause of it that I didn't add "--armor" parameter when exporting my private key?
Thanks.
Re: Problems when importing previously exported private keys on new linux system. [ In reply to ]
On 08/08/2022 22:36, Vladislav Alekseev via Gnupg-users wrote:

> So, here is the problem.
> Is there any method to restore my private key or revoke it?
> Why gpg program can't identify my key file? Is the root cause of it that
> I didn't add "--armor" parameter when exporting my private key?
> Thanks.

Check the key format manually. If ASCII - try `dos2unix`. Sounds like it
has been transferred between Windows/*nix. If binary, show the output of
`gpg --list-packets`



--
Glory to Ukraine,
A

_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-users
Re: Problems when importing previously exported private keys on new linux system. [ In reply to ]
On 2022-08-08 at 13:06 +0000, Vladislav Alekseev wrote:
> So, here is the problem.
> Is there any method to restore my private key or revoke it?
> Why gpg program can't identify my key file? Is the root cause of it
> that I didn't add "--armor" parameter when exporting my private key?
> Thanks.

The missing --armor shouldn't make a difference here.

What was the gpg version in the old system and which is the version in
the new one? Is it possible that the new system is using an *older*
version of gpg?


_______________________________________________
Gnupg-users mailing list
Gnupg-users@gnupg.org
https://lists.gnupg.org/mailman/listinfo/gnupg-users
Problems when importing previously exported private keys on new linux system. [ In reply to ]
Sorry for replying late, this is my first use with mailing list and I didn't notice your email.

Unfortunately, I forgot the gnupg version number on my old linux. But as I created cron tasks to have my system update daily, I think it's up to date with apt. I'll provide other assistance if you want me to.

I've talked the thing with Andrew Savchenko <andrew@savchenko.net>, but I didn't know I should CC to gnupg-users@gnupg.org to make my mails visible to all users.

If you want and permit me to, I will forward all my emails with Andrew here.

When I trying to recover my keys, I found something interesting. (I had shared it with Andrew)
I'm working on Windows these days, and I found something interesting.
I created a new key pair and then export private key both with "-a" parameter and without.
Then when I tried to re-import them, the same error occurred with both key files.
But, when I manually copy content in armored private key file and paste it after "gpg --import" command, it worked as expected.

To sum up, it seems that if I am restoring a key from file, it won't work.
If I copy from a armored file and then paste to shell, it will work as expected.
?I created a linux machine today and all the actions succeeded as expected. I also export my keys and download it to my windows (both armored and not), and succeeded to import, failed to export to file then re-import.

I'll post my keys, environment and version data here once I reach my Windows laptop.

Regards.
V