I am unable to export my gpg keys from Machine#1 to Machine#2 (See below). I have an error message when I try to import the secret key error sending to agent: Permission denied I do not know what this means and can find on explaination on the web. The Key ID being imported seems wrong and, when I look into the .gnupg directory the zero length agent files seem wrong. What am I doing wrong. The process that I used to export and then import the keys are documented below.
Machine#1
tim@Machine#1:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.4 LTS
Release: 16.04
Codename: xenial
tim@Machine#1:~$
tim@Machine#1:~$ ls -l .gnupg
total 36
-rw------- 1 tim tim 9398 Feb 11 20:08 gpg.conf
-rw------- 1 tim tim 2398 Mar 17 18:15 pubring.gpg
-rw------- 1 tim tim 2398 Mar 17 18:15 pubring.gpg~
-rw------- 1 tim tim 600 May 24 18:49 random_seed
-rw------- 1 tim tim 5186 Mar 17 18:15 secring.gpg
-rw------- 1 tim tim 1360 Mar 17 18:15 trustdb.gpg
tim@Machine#1:~$
tim@Machine#1:~$ gpg --version
gpg (GnuPG) 1.4.20
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
tim@Machine#1:~$
Machine#2
tim@Machine#2:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.2 LTS
Release: 18.04
Codename: bionic
tim@Machine#2:~$
tim@Machine2:~$ gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: /home/tim/.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
tim@Machine2:~$
tim@Hear2Read2:~$ gpg --fingerprint
/home/tim/.gnupg/pubring.gpg
----------------------------
pub 2048R/83EB69F3 2020-02-11
Key fingerprint = 0343 CF48 7E72 4B8C C8BE 51C0 47FB 83BC 83EB 69F3
uid Timothy White (Developer) <tim@hear2read.org>
sub 2048R/2F1932FB 2020-02-11
pub 2048R/FE4572BD 2020-03-17
Key fingerprint = AA0D 9A6B 55E7 DBC1 0FB5 93EF 9866 EEF5 FE45 72BD
uid Timothy White <flite@hear2read.org>
sub 2048R/0134F557 2020-03-17
//.gnupg listing was done after the import failed.
tim@Machine#2:~$ ls -l .gnupg
total 20
srwx------ 1 tim tim 0 May 30 17:48 S.gpg-agent
srwx------ 1 tim tim 0 May 24 18:53 S.gpg-agent.browser
srwx------ 1 tim tim 0 May 24 18:53 S.gpg-agent.extra
srwx------ 1 tim tim 0 May 24 18:53 S.gpg-agent.ssh
drwx------ 2 tim tim 4096 May 24 18:53 private-keys-v1.d
-rw-rw-r-- 1 tim tim 4170 May 30 17:43 pubring.kbx
-rw-rw-r-- 1 tim tim 2794 May 30 17:43 pubring.kbx~
-rw------- 1 tim tim 1200 May 24 18:53 trustdb.gpg
tim@Machine#2:~$
Export Keys from Machine#1
tim@Machine#1:~$ gpg --armor --export --output keys_pub.gpg
tim@Machine#1:~$ gpg --armor --export-secret-keys --output keys_sec.gpg
gpg files are copied to Machine#2
Import Keys to Machine#2
tim@Machine#2:~$ gpg --import keys_pub.gpg
gpg: key 47FB83BC83EB69F3: public key "Timothy White (Developer) <tim@hear2read.org>" imported
gpg: key 9866EEF5FE4572BD: public key "Timothy White <flite@hear2read.org>" imported
gpg: Total number processed: 2
gpg: imported: 2
tim@Machine#2:~$ gpg --import keys_sec.gpg
gpg: key 47FB83BC83EB69F3: "Timothy White (Developer) <tim@hear2read.org>" not changed
gpg: key 47FB83BC83EB69F3/47FB83BC83EB69F3: error sending to agent: Permission denied
gpg: error building skey array: Permission denied
gpg: key 9866EEF5FE4572BD: "Timothy White <flite@hear2read.org>" not changed
gpg: key 9866EEF5FE4572BD/9866EEF5FE4572BD: error sending to agent: Permission denied
gpg: error building skey array: Permission denied
gpg: Total number processed: 2
gpg: unchanged: 2
gpg: secret keys read: 2
tim@Machine#2:~$
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Try this.
gpg --allow-secret-key-import --import --pinentry-mode loopback keys_sec.gpg
try to use root privileges, such as sudo gpg … I think that gpg elevated without permissions does not refer to file permissions, but system