date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,679,997,093,000 |
I have changed to Fedora Linux and shrunk my windows partition. I have unallocated space which I want Fedora to take up. I have looked other answers to questions like this and cannot find instructions for my use case. I have a picture of my drive right now. I also have a live USB ready.
From what I have read so far, I shouldn't touch the boot partition. Can someone give me instructions on how to get around the /boot? I will need to move it later as well to give more space to Fedora.
In short, how do I move the Fedora partition to before the boot ext4 partition and resize it?
|
how do I move the Fedora partition to before the boot ext4 partition and resize it?
The answer may be surprising: You don't have to do that.
Since you are using LVM and are not aiming to extend a non-LVM partition (i.e. /boot), you don't have to extend the existing PV. Instead, you can make a new partition out of the unallocated space, use pvcreate to make it a second LVM PV, then vgextend to add it into your existing volume group.
With LVM, your volume group may consist of one PV, or many PVs, on one or more disks; LVM does not care about that. All the PVs in a single VG will act together as a single pool of disk space. You can then extend or create new LVs freely, without needing to care where one PV ends and another begins. It will all be handled transparently by LVM.
First, use gparted or any tool you like to make that unallocated space into an usable partition. You should set its type ("flags" in gparted) as lvm2 pv, but strictly speaking you don't have to. I'll assume that it will be named /dev/nvme0n1p7.
Verify that the new partition is visible in /proc/partitions, indicating that the kernel has accepted the new partition table. If that did not happen, you may need to run partprobe /dev/nvme0n1 and check again. If the partition is still not recognized by the kernel, you may need to reboot at this point.
Once the partition is visible, you can proceed. Use pvs to see if gparted already initialized the partition as a LVM PV; if not, run pvcreate /dev/nvme0n1p7 to initialize it.
Then, assuming that your LVM volume group uses the default name fedora, run vgextend fedora /dev/nvme0n1p7.
Now the previously-unallocated space has been added to the volume group, and you can use it to extend existing LVs and/or create new ones as you wish.
| How can I resize my fedora lvm partition to be larger with the root partition in the way? |
1,679,997,093,000 |
Below is the info I get using (g)parted or fdisk command.
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 196265983 196263936 93.6G 83 Linux
/dev/sda2 196268030 229468159 33200130 15.9G 5 Extended
/dev/sda5 196268032 229468159 33200128 15.9G 82 Linux swap / Solaris
Is there a system call or filesystem(/sys/block, etc) based info available to know if a partition is extended/primary and the hierarchy sda5 under sda2, etc?
If yes, is there a way to know if what logical partitions lie under the selected extended partition?
I want to avoid parsing output of command(s). I have tried to read the code of fdisk but it is too complex for me to understand it.
Edit 1:
After reading the comments and answers I came to know that I was not aware of MBR/GPT, etc. So, I decided to read about MBR and EBR internals https://thestarman.pcministry.com/asm/mbr/PartTables2.htm#ebr and wrote a code to get the partition details of a disk.
|
This question is not well defined.
If the disk is formatted using GPT, then there are no extended partitions, and so there is no heirarchy.
If the disk is formatted using MBR in such a way that a Microsoft OS can access it, then there is at most 1 extended partition, and a total of up to 4 primary and extended partitions. These will have names of the form /dev/sdf[0-3]. If there are any logical partitions, they will have partition numbers greater than 4. In order to have logical partitions you must have an extended partition to hold them.
However there is nothing requiring a linux system to have at most one extended partition, and there is nothing to say that there can be no overlaps of non-extended partitions, just as long as you don't use them.
So in particular you could have partition 1 being a smallish boot partition, partition 2 covering everything that wasn't in partition 1, partition 3 covering the first half of partition 2 and being of type "extended", partition 4 being the second half of partition 2. Inside partition 3 you could have partitions 5 and 6, each taking half of partition 3. This will all work OK provided that you don't actually try and use partition 2. However partitions 5 and 6 are both in both partitions 2 and 3, so the "hierarchy" is not a DAG (Directed Acyclic Graph), and so the "client need" can't be satisfied.
My advice for clients like this is to double your fees.
The "type" of the partition for the primary/extended is recorded in the MBR, so you can use code like dd bs=1 skip=446 count=64 if=/dev/sdf | hexdump -C to get something like this
00000000 00 20 21 00 83 df 13 0c 00 08 00 00 00 20 03 00 |. !.......... ..|
00000010 00 df 14 0c 05 19 0d cc 00 28 03 00 00 e0 2e 00 |.........(......|
00000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000030 00 19 0e cc 83 15 50 05 00 08 32 00 00 f8 0d 00 |......P...2.....|
and you can pick out the 5th byte (83, 05, 00, 83) to get the 4 values. The usual "type" of an extended partition is 05, but 0f and 85 are also used. See https://www.win.tue.nl/~aeb/partitions/partition_types-1.html for more information.
So with this you see if there is an extended partition (the second one in this case), and you then know that partitions with numbers greater than 4 are in it.
| How to check if partition is Extended/Primary in Linux |
1,679,997,093,000 |
This question is very vague, so allow me to be more specific:
I divided my USB drive (a temporary storage device until I get an SSD) into 6 partitions using GParted. I planned to use Rufus to install multiple Linux distros (up to 6), but I forgot that it actually identifies the whole USB drive, not individual partitions. The partition table is formatted as GPT, and each partition is ext4.
I also don't know how that would work, since wouldn't the GRUB boot loader install on each partition? Would this cause any flaws? Should I make a partition containing only GRUB?
I am still learning the concepts of Linux OSes so I'll be at a slow pace. My main goal is to be able to boot up any OS of Linux I have installed by choosing it in the GRUB or something of the sort.
|
Should I make a partition containing only GRUB? I am still learning the concepts of Linux OSes so I'll be at a slow pace. My main goal is to be able to boot up any OS of Linux I have installed by choosing it in the GRUB or something of the sort.
GRUB = Grand Unified Boot Loader
yes, it would make sense to partition your [USB] drive to something like this for example, Grub is a boot loader that can boot anything hence its name:
format disk partition table as GPT, since that will handle anything. Using the legacy MBR will only allow for 3 or 4 partitions and have other problems (research difference between MBR and GPT as well as UEFI vs BIOS).
make first partition called boot, and format as either EXT2 or EXT3 would be my recommendation since those file systems will be readable by anything. Install GRUB on this partition. Basically the boot process from EFI, or BIOS, on your motherboard will then read GRUB on this partition; and GRUB will handle everything from here on.
you then need to configure GRUB {this is what makes it grand} and then upon booting when GRUB runs it will prompt with a bunch of menu options to those linux distro's you've installed on N partitions.
you will need to learn the in and outs of GRUB, probably GRUB2 since that's what's current now, to do this effectively
you will need to plan ahead for how many linux distro's you want when making partition sizes. Partition 1 {boot} at a size of 1GB for GRUB2 would be plenty. Leave rest of disk as free space, and if you did 100GB partitions for each linux distro that would let you do 9 distro's on a 1TB disk for example.
during a linux install tell it the existing /boot partition on partition 1 with your GRUB2, then partitition 2..n will be the root partition for that linux distro. Whether the linux install is smart enough to recognize GRUB2 already existing and modifying it I don't know. So partition 1 called and labelled /boot will contain GRUB2 and all the linux bootable images that you've installed, and then in each of those will reference their corresponding root partition from partitions 2..n.
Partition 1 that boot partition will have just one instance of GRUB2 configured to recognize all the linux distro's installed where each linux distro's kernel executable (files such as vmlinuz-3.0.101-108.77-default) will all be on this partition. Problem you may run into is if one distro uses the same name file as another, so you may want to manually organize partition 1 mounted as /boot to something like /boot/grub and /boot/rhel7 and /boot/sles11 and /boot/centos7 and /boot/ubuntu and so on.
Using Rufus or whatever tool to format USB flash memory as a bootable device, just use Rufus to put a GPT partition table on it but leave the entire thing free space, you just want to make it so as acceptable storage {disk} space when doing a linux install.
| How should I configure my drive to be able to boot from multiple distros of Linux? |
1,424,003,876,000 |
I'm trying to copy my gpg key from one machine to another.
I do:
gpg --export ${ID} > public.key
gpg --export-secret-key ${ID} > private.key
Move files to new machine, and then:
gpg --import public.key
gpg: nyckel [ID]: public key [Name, e-mail] was imported
gpg: Total number of treated keys: 1
gpg: imported: 1 (RSA: 1)
gpg --allow-secret-key-import private.key
sec [?]/[ID] [Creation date] [Name, e-mail]
ssb [?]/[SUB-ID] [Creation date]
All looks good to me, but then:
$ gpg -d [file].gpg
gpg: encrypted with 4096-bit RSA-key, id [SUB-ID], created [Creation date]
[Name, e-mail]
gpg: decryption failed: secret key not accessible
So the error message says that the file has been encrypted with [SUB-ID], which the secret key import appears to say it has imported. (The [SUB-ID] in both messages is the same).
So I'm clearly doing something wrong, but I don't know what.
|
You need to add --import to the command line to import the private key. (You don't need to use the --allow-secret-key-import flag. According to the man page: "This is an obsolete option and is not used anywhere.")
gpg --import private.key
| How to import secret gpg key (copied from one machine to another)? |
1,424,003,876,000 |
I have generated keys using GPG, by executing the following command
gpg --gen-key
Now I need to export the key pair to a file;
i.e., private and public keys to private.pgp and public.pgp, respectively.
How do I do it?
|
Export Public Key
This command will export an ascii armored version of the public key:
gpg --output public.pgp --armor --export username@email
Export Secret Key
This command will export an ascii armored version of the secret key:
gpg --output private.pgp --armor --export-secret-key username@email
Security Concerns, Backup, and Storage
A PGP public key contains information about one's email address. This is generally acceptable since the public key is used to encrypt email to your address. However, in some cases, this is undesirable.
For most use cases, the secret key need not be exported and should not be distributed. If the purpose is to create a backup key, you should use the backup option:
gpg --output backupkeys.pgp --armor --export-secret-keys --export-options export-backup user@email
This will export all necessary information to restore the secrets keys including the trust database information. Make sure you store any backup secret keys off the computing platform and in a secure physical location.
If this key is important to you, I recommend printing out the key on paper using paperkey. And placing the paper key in a fireproof/waterproof safe.
Public Key Servers
In general, it's not advisable to post personal public keys to key servers. There is no method of removing a key once it's posted and there is no method of ensuring that the key on the server was placed there by the supposed owner of the key.
It is much better to place your public key on a website that you own or control. Some people recommend keybase.io for distribution. However, that method tracks participation in various social and technical communities which may not be desirable for some use cases.
For the technically adept, I personally recommend trying out the webkey domain level key discovery service.
| How to export a GPG private key and public key to a file |
1,424,003,876,000 |
What is the best way to renew a gpg key pair when it got expired and what is the reason for the method?
The key pair is already signed by many users and available on public servers.
Should the new key be a subkey of the expired private key?
Should it be signed by the old (I could try to edit the key and change the date of expiration to tomorrow)?
Should the new key sign the old?
|
Private keys never expire. Only public keys do. Otherwise, the world would never notice the expiration as (hopefully) the world never sees the private keys.
For the important part, there is only one way, so that saves a discussion about pros and cons.
You have to extend the validity of the main key:
gpg --edit-key 0x12345678
gpg> expire
...
gpg> save
You have to make a decision about extending validity of vs. replacing the subkey(s). Replacing them gives you limited forward security (limited to rather large time frames). If that is important to you then you should have (separate) subkeys for both encryption and signing (the default is one for encryption only).
gpg --edit-key 0x12345678
gpg> key 1
gpg> expire
...
gpg> key 1
gpg> key 2
gpg> expire
...
gpg> save
You need key 1 twice for selecting and deselecting because you can extend the validity of only one key at a time.
You could also decide to extend the validity unless you have some reason to assume the key has been compromised. Not throwing the whole certificate away in case of compromise makes sense only if you have an offline main key (which IMHO is the only reasonable way to use OpenPGP anyway).
The users of your certificate have to get its updated version anyway (either for the new key signatures or for the new key(s)). Replacing makes the key a bit bigger but that is not a problem.
If you use smartcards (or plan to do so) then having more (encryption) keys creates a certain inconvenience (a card with the new key cannot decrypt old data).
| How to renew an expired keypair with gpg |
1,424,003,876,000 |
While trying to receive keys in my Debian Stretch server, I get this error:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Executing: /tmp/apt-key-gpghome.4B7hWtn7Rm/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: failed to start the dirmngr '/usr/bin/dirmngr': No such file or directory
gpg: connecting dirmngr at '/tmp/apt-key-gpghome.4B7hWtn7Rm/S.dirmngr' failed: No such file or directory
gpg: keyserver receive failed: No dirmngr
|
Installing the package dirmngr fixed the error.
user@debian-server:~$ sudo apt-get install dirmngr
Retrying :
user@debian-server:~$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Executing: /tmp/apt-key-gpghome.haKuPppywi/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: key A6A19B38D3D831EF: public key "Xamarin Public Jenkins (auto-signing) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
| gpg: keyserver receive failed: No dirmngr |
1,424,003,876,000 |
I am trying to add a public key for installing a program with CPG. But I am pretty new to this but every command I found gave me the same error:
gpg --keyserver keyserver.ubuntu.com --recv-keys 94558F59
gpg: requesting key 94558F59 from hkp server keyserver.ubuntu.com
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
How is this possible it seems that the I am behind some kind of blockade which makes it impossible to establish a connection to the key server. I looked into many OP questions and tried all commands I could find but nothing worked. Anyone had this problem before?
|
This is usually caused by your firewall blocking the port 11371. You could unblock the port in your firewall. In case you don't have access to the firewall you could:
Force it to use port 80 instead of 11371
$ sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 94558F59
-or alternatively omitting the port-
$ sudo gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 94558F59
Alternatively
Find and open the key from the key server.
Copy it's contents into a text file.
Go to System Tool > Preferences > Software Sources > Authentication > Add key, and select the text file created. Ubuntu 14.04 and later try: Software Center -> Edit -> Software Sources -> Authentication -> Import key file
| keyserver timed out when trying to add a GPG public key |
1,424,003,876,000 |
When I list the details of a key I get output like this:
$ gpg --edit-key SOMEID
pub [..] created: [..] expires: [..] usage:SC
[..]
sub [..] created: [..] expires: [..] usage: E
Or even usage: SCA on another key (the master-key part).
What does these abbreviation in the usage field mean?
I can derive that:
S -> for signing
E -> for encrypting
But what about C and A?
And are there more?
And where to look stuff like this up?
|
Ok, the gpg manual does not seem to mention these abbreviations. Thus, one has to look at the source.
For example under Debian/Ubuntu:
$ apt-get source gnupg2
$ cd gnupg2-2.0.17
$ cscope -bR
$ grep 'usage: %' . -r --exclude '*po*'
$ vim g10/keyedit.c
jump to usage: %
jump to definition of `usagestr_from_pk`
From the code one can derive following table:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Constant Character
───────────────────────────────
PUBKEY_USAGE_SIG S
PUBKEY_USAGE_CERT C
PUBKEY_USAGE_ENC E
PUBKEY_USAGE_AUTH A
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Thus, for example, usage: SCA means that the sub-key can be used for signing, for creating a certificate and authentication purposes.
| How are the GPG usage flags defined in the key details listing? |
1,424,003,876,000 |
This error has arise when I add gns repository and try to use this command:
#sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F88F6D313016330404F710FC9A2FD067A2E3EF7B
the error is:
gpg: keyserver receive failed: Server indicated a failure
|
Behind a firewall you should use the port 80 instead of the default port 11371 :
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9A2FD067A2E3EF7B
Sample output:
Executing: /tmp/apt-key-gpghome.mTGQWBR2AG/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv 9A2FD067A2E3EF7B
gpg: key 9A2FD067A2E3EF7B: "Launchpad PPA for GNS3" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
| gpg: keyserver receive failed: Server indicated a failure |
1,424,003,876,000 |
I did a clean install of Arch Linux and imported my backed up gpg private key. As a sanity check I ran:
gpg —list-keys
Everything showed up as normal except for the uid which now reads:
uid [ unknown ] User < [email protected] >
When I first created this key before the clean install it read:
uid [ ultimate ] User < [email protected] >
Why would it change from [ ultimate ] to [ unknown ]after importing it onto a clean install?
Thanks in advance.
|
GNUPG has a trust database stored at ~/.gnupg/trustdb.gpg
You can backup this trust database using the --export-ownertrust option:
gpg --export-ownertrust > file.txt
If you exported your secret keys and import them later into a new environment, the trust database is no longer present.
However, this is easily remedied:
gpg --edit-key [email protected]
gpg> trust
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
Your decision? 5
And don't forget to save the changes:
gpg> save
Read about trust levels and values. E.g. unknown Nothing is known about the owner's judgement in key signing. Keys on your public keyring that you do not own initially have this trust level.
| gpg —list-keys command outputs uid [ unknown ] after importing private key onto a clean install |
1,424,003,876,000 |
Adding a gpg key via apt-key systematically fails since I've switched to Ubuntu 17.04 (I doubt it's directly related though). Example with Spotify's repo key:
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
Executing: /tmp/apt-key-gpghome.wRE6z9GBF8/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
gpg: keyserver receive failed: No keyserver available
Same thing if I remove the hkp:// prefix.
Context: I use CNTLM to cope with the local corporate proxy. Env variables are set (in /etc/environment):
$ env | grep 3128
https_proxy=http://localhost:3128
http_proxy=http://localhost:3128
ftp_proxy=http://localhost:3128
/etc/apt/apt.conf is configured (apt commands are working fine):
$ cat /etc/apt/apt.conf
Acquire::http::Proxy "http://localhost:3128";
Acquire::https::Proxy "http://localhost:3128";
Acquire::ftp::Proxy "http://localhost:3128";
Finally, the specified keyserver seems reachable:
$ curl keyserver.ubuntu.com:80
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SKS OpenPGP Public Key Server</title>
</head>
<body>
[...]
What can I do ? I'm not even sure on how to further debug it...
Things I already tried to do, without any result:
run sudo with -E (preserve env) option
run apt-key adv with --keyserver-options http-proxy=http://localhost:3128/ option (source)
run $ gpg --list-keys for some reason (source)
use another keyserver (--keyserver pgp.mit.edu)
remove the hkp:// part (--keyserver keyserver.ubuntu.com:80)
Weird thing is that I never see any "cntlm" entry in /var/log/syslog when running apt-key.
|
You usually have a proxy for ftp, http and https; I am seeing there hkp:// as an URL; so it should not be directed via a pure http proxy, hence failing the communication.
Use this instead:
sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy=http://localhost:3128 --recv-keys BBEBDCB318AD50EC6865090613B00F1FD2C19886
As for the system updates, I would advise using an APT proxy, for instance, apt-cacher-ng.
Another way of doing it, is searching in the public web interface, with a browser, for instance on your working station for the key you want at https://keyserver.ubuntu.com
Open the site, and you got a form. In this case I used the "Search String" "Spotify"; then select "Search" ; it will list several keys.
Searching for the signature/fingerprint that you mentioned in the result page:
pub 4096R/D2C19886 2015-05-28
Fingerprint=BBEB DCB3 18AD 50EC 6865 0906 13B0 0F1F D2C1 9886
uid Spotify Public Repository Signing Key <[email protected]>
sig sig3 D2C19886 2015-05-29 __________ 2017-11-22 [selfsig]
sig sig 94558F59 2015-06-02 __________ __________ Spotify Public Repository Signing Key <[email protected]>
We see this is the entry that interests us.
So we click in D2C19886 and are presented with a page with the key at https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x13B00F1FD2C19886.
Public Key Server -- Get "0x13b00f1fd2c19886 "
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6
Comment: Hostname: keyserver.ubuntu.com
mQINBFVm7dMBEADGcdfhx/pjGtiVhsyXH4r8TrFgsGyHEsOWaYeU2JL1tEi+YI1qjpExb2Te
TReDTiGEFFMWgPTS0y5HQGm+2P3XGv0pShvgg9A6FWZmZmT+tymA2zvNrdpmKdhScZ52StPL
Fz9wsmXHG4DIKVuzgzuV4YxJ1i2wFtoVp8zT9ORu1BxLZ0IBwTvLRbaQGZ8DwXVAHak9cK91
Ujj6gJ1MJPohZLHH2BjrOjEl/I36jFUjK0AadznNzo08lLAi94qjtheJtuJD3IEOAlCkaknz
6vbEFpszLGlLD7GENMzJk46ObuJuvW5R2PkOU2U8jS0GaUD9Ou/SIdJ6vIdvjSs/ettc2wwd
nbSdadvjovIfvEBRsEVMpRG+42B+DZpJbS9pCb8sxTJtnUy1YViZmG0++FhPGGPGzQYhC/Mz
07lsx5PkC7Kka2FCNmhauxw5deO43Ck181oQVdbt/VxmChzchUJ6N6/uOV5JKm7B9UnDNyqU
Yv6goeLvFnT9ag+FCxiroTrq+dINr6d+XT/cI9WtSagfmhcekwhyfcCgYsFemAOckRifjEGF
MksQlnWkGwWNoKe91KBxjgaJaazSbZRk0dFPSSmfKWaxuTwkR74pbaueyijnQJgHAjfCyzQe
9miN9DitON5l6T2gVAN3Jn1QQmV7tt5GB7amcHf5/b0oYmmRPQARAQABtD5TcG90aWZ5IFB1
YmxpYyBSZXBvc2l0b3J5IFNpZ25pbmcgS2V5IDxvcGVyYXRpb25zQHNwb3RpZnkuY29tPokB
HAQQAQIABgUCVW3SWAAKCRAILM7flFWPWUk5B/wOqqD9/2Do9PyPucfUs/rrP4+M8iJLpv8U
+bX/qHryTTWfpk3YuKL4+c8saHySK4HLGyxd3mdo1XMF351KrxLQvWMSSPbIRV9cSqZROOVn
2ya+3xpWk6t1omLzxtBBMOC4B5qAfWhog7ioAmzQNY5NUz5mqXVP5WbgR/G+GOszzuQUgeu1
Xxxzir3JqWQ0g8mp3EtX7dB76zxkkuTYbeVDPOvtJPn/38d3oSLUI1QJnL8pjREHeE8fO5mW
ncJmyZNhkYd+rfnPk+W0ZkTr59QBIEOGMTmATtNh+x1mo5e2dW91Oj4jEWipMUouLGqbo/gJ
uHFMt8RWBmy+zFYUEPYHiQI+BBMBAgAoAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUC
VWg3sAUJBK3QLQAKCRATsA8f0sGYhl6hEACJ1CrYjaflKKR2Znuh0g0gM89NAwO8AA4+SpkW
HagdGLo7OV/rGB3mlwD4mhaa8CbEnBT/za3jFnT19KsYQWiT21oOX/eo47ITbAspjDZTiXLi
nyAcOJn+q/EFkelROzbVaxZHi6SN5kCEd8KAew8h2jZf8wWqaYVyMPNSqotUhin6YjWsu57B
GixVThoMmxx3udsGAiYqt8buAANWbkUphrvtJuNCKkGym7psnS4Q5EnHPfvbYii9iAfBswX6
nZQlehva7aToN73elYL3opCArAxKAFx70bpGxb7T16KjKzkKS0a4iQ7xdbBGylb+AE/RhICa
+RM5tma2YnB3pZvFM/n0BNeYReCgvxkl1rqrB1KxmFHfGqjLkb2YAZ5RYnP3gEt+nbEWxL8F
O0Bhakn1RB3NqTC2oiQAUfh+66yUawUNkHRHlGAEzZAxvpfnf0hSJp734lyQZJs+zqXUAXa2
UmEZ6se62PgZRQIz5IbAVxSiGz4xIZs1yS36N2vZ34LFJa9o/HVk5OfpqZM0zjWwQIQN2b4O
BizL5r4h2Mi5BHUEyYMsDZn+txoJjPPYLolRlf31sqi5MJE+cbOAXSn8PC9k4i+hrbfqFzts
47+6xgCH3aXbhUkJh1CH/0/qEXfTPYTyayijm4rdvSBczzEORWGT5E38oV9h1eUqp4nVPg==
=/qip
-----END PGP PUBLIC KEY BLOCK-----
You cut between the line that begins with "-----BEGIN" and the line ending with "-----END", including those lines, and paste to a file, say spotify.pgp on the intended server you want to import that key. (do not cut it from here, as I added 4 spaces before each line while formatting)
Finally to import the key into the server you do:
$sudo apt-key add spotify.pgp
OK
| Unable to add gpg key with apt-key behind a proxy |
1,424,003,876,000 |
ssh-add -l shows you all ssh-keys that have been added with ssh-add ~/.ssh/id_yourkey. How do I do the analogous thing with gpg and gpg-agent, in other words, ask it to show a list of cached keys?
|
You may not be able to do this, at least not yet, or at least not in the general case. However, I will share what I have learned, and look forward to updating this answer in due course.
First of all, unlike the ssh-agent capability, which actually caches private keys, gpg-agent can cache either keys or passphrases. It is up to each client which to cache, and gpg just uses gpg-agent to cache the passphrase.
You can interact with gpg-agent using the gpg-connect-agent utility. In the example that follows, I am passing commands one at a time via STDIN.
$ CACHEID="ThisIsTheTrickyPart"
$ ERRSTR="Error+string+goes+here"
$ PMTSTR="Prompt"
$ DESSTR="Description+string+goes+here"
$ echo "GET_PASSPHRASE --data $CACHEID $ERRSTR $PMTSTR $DESSTR" | gpg-connect-agent
D MyPassPhrase
OK
Upon invoking gpg-connect-agent and passing in this command, the pinentry command configured on my system uses the error, prompt, and description strings to prompt for a passphrase. In this case I entered "MyPassPhrase" which is what is returned in the structured output (see image below). If I send GET_PASSPHRASE to gpg-agent again with the same $CACHEID, it returns the cached passphrase instead of using pinentry.
GET_PASSPHRASE also accepts a --no-ask option which will return an error on a cache miss. Here I use "NotCachedID" as the cache ID, and use dummy strings for the required arguments that gpg-agent will not use.
$ echo "GET_PASSPHRASE --no-ask NotCachedID Err Pmt Des" | gpg-connect-agent
ERR 67108922 No data <GPG Agent>
In principle, then, you could ask the agent for each maybe-cached passphrase in turn, and check for OK or ERR in the output. The question then becomes, how do I generate the cache ID? As we see in the example above, gpg-agent is liberal in what it accepts as the cache ID. It turns out that gpg computes a fingerprint on the public key and uses a hex-coded string representation as the cache ID, but the trouble is that this fingerprint is not the same as the fingerprint you can learn via gpg --fingerprint --list-secret-keys. This digest is called keygrip (because it is computed over the raw key material only whereas the fingerprint is calculcated over the key material and the creation timestamp). If you really want to continue down this path, you will have to find out how to generate the correct fingerprint for each of the keys you wish to check (this will be easy using the next generation of GnuPG, 2.1, with the option --with-keygrip).
Warning: The output from GET_PASSPHRASE actually contains the passphrase in the clear. Even if you leave off the --data option, the passphrase is plainly visible as a hex-coded string. It is probably a Very Bad Idea(tm) to muck around with this unless you know what you are doing, and take the appropriate precautions.
| How can I find out what keys gpg-agent has cached? (like how ssh-add -l shows you cached ssh keys) |
1,424,003,876,000 |
System: I am testing Linux Mint 19 Beta based on Ubuntu 18.04.
I got this warning while installing an unrelated package:
gpg: WARNING: unsafe ownership on homedir '/home/vlastimil/.gnupg'
This is the ls output the of the directory itself:
$ lld /home/vlastimil/.gnupg
drwx------ 4 vlastimil vlastimil 4,0K Jun 26 11:42 /home/vlastimil/.gnupg
That seems to be OK.
This is the ls output the contents of the directory:
$ ll /home/vlastimil/.gnupg/
total 24K
drwx------ 2 vlastimil vlastimil 4,0K Jun 26 11:36 crls.d
drwx------ 2 vlastimil vlastimil 4,0K Jun 26 05:28 private-keys-v1.d
-rw-r--r-- 1 vlastimil vlastimil 6,4K Jun 26 11:42 pubring.kbx
-rw-r--r-- 1 vlastimil vlastimil 3,2K Jun 26 11:37 pubring.kbx~
srwx------ 1 root root 0 Jun 26 11:38 S.dirmngr
-rw------- 1 vlastimil vlastimil 1,2K Jun 26 11:37 trustdb.gpg
I am unsure if I can't just delete the seemingly offending directory named S.dirmngr.
I am also unsure if that would solve the issue or create another one.
I just remember that not long ago, I was instructed to install a package named like that, i.e. dirmngr, but I can't remember with what software installation it was connected.
EDIT1:
As StephenKitt pointed out, I really ran this line, I have found in the history:
sudo gpg --recv-keys ...
Will this have any consequences?
|
This is the result of running gpg with sudo: gpg then runs as root, but its home directory is still the user’s. This explains both the warning (gpg is running as root but another user owns the configuration directory) and dirmngr’s socket’s ownership.
To fix this up, you should stop dirmngr:
sudo gpgconf --kill dirmngr
(sudo just this once because dirmngr is running as root, as evidenced by its socket), then restore your ownership:
sudo chown -R $USER ~/.gnupg
| gpg: WARNING: unsafe ownership on homedir '/home/user/.gnupg' |
1,424,003,876,000 |
I have a line in my gpg.conf file which says use-agent.
I understand this refers to gpg-agent which is a daemon.
The man page states "gpg-agent is a daemon to manage secret (private) keys independently from any protocol. It is used as a backend for gpg and gpgsm as well as for a couple of other utilities."
Can anybody explain what this means in the context of gpg? What is the point of gpg-agent?
I have GPG 1.4 at present.
How can I tell whether the agent is running? I'm actually not even clear on whether gpg-agent is installed with the basic GPG 1.4 package.
How can I start it, if it is not running?
How can I stop it, if it is running?
|
Gpg-agent is a program that runs in the background (a daemon) and stores GPG secret keys in memory. When a GPG process needs the key, it contacts the running gpg-agent program through a socket and requests the key. If the agent process has the key, it provides it to gpg. If it doesn't, it attempts to load the encrypted key from your keyring, and prompts you for the key's passphrase. Once the agent has obtained the decrypted key, it passes it to the gpg process. In addition to GPG keys, Gpg-agent can similarly store SSH keys and provide them to SSH processes, like the ssh-agent program that comes with SSH.
The main point of using a key agent is so that you don't have to type your passphrase every single time you use your key. The agent keeps the key in memory from one time to the next. GPG itself can't do that because the process terminates once it's done its job.
Another thing that a key agent can do is allow GPG running on a remote machine to obtain keys in the local agent (which may load them from a local file and prompt for your passphrase). Gpg-agent can't do this yet, it is a planned feature. SSH has had agent forwarding for a very long time. (This is a reason not to use gpg-agent for SSH keys.)
GPG 1.x or 2.0.x knows that the agent is running because the GPG_AGENT_INFO variable is set. This variable contains the location of the socket to communicate with the agent as well as the process ID of the agent. GPG 2.1 always places the agent socket in ~/.gnupg. GPG 2.x always starts an agent process if one isn't running.
You can start the agent simply by running gpg-agent. If you want to keep an agent process as part of your session, you can replace the invocation of your session manager by gpg-agent my-session-manager; some distributions set this up automatically. GPG will automatically start the agent, and GPG 2.1 will additionally find a running agent without needing an environment variable, so you don't need to start it this way unless you use an older version of GPG or you use the agent to store other types of keys such as SSH.
You can send the agent commands with the gpg-connect-agent shell command. Send the kill command to kill the agent process (or send it a signal).
Gpg-agent ships with GPG itself. Some distributions package it separately.
| How does GPG agent work? |
1,424,003,876,000 |
I renewed my gpg key pair, but I am still receiving the following error from gpg.
gpg: WARNING: Your encryption subkey expires soon.
gpg: You may want to change its expiration date too.
How can I renew the subkey?
|
List your keys.
$ gpg --list-keys
...
-------------------------------
pub rsa2048 2019-09-07 [SC] [expires: 2020-11-15]
AF4RGH94ADC84
uid [ultimate] Jill Doe (CX) <[email protected]>
sub rsa2048 2019-09-07 [E] [expired: 2019-09-09]
pub rsa2048 2019-12-13 [SC] [expires: 2020-11-15]
7DAA371777412
uid [ultimate] Jill Doe <[email protected]>
-------------------------------
...
We want to edit key AF4RGH94ADC84.
The subkey is the second one in the list that is named ssb
$ gpg --edit-key AF4RGH94ADC84
gpg> list
sec rsa2048/AF4RGH94ADC84
created: 2019-09-07 expires: 2020-11-15 usage: SC
trust: ultimate validity: ultimate
ssb rsa2048/56ABDJFDKFN
created: 2019-09-07 expired: 2019-09-09 usage: E
[ultimate] (1). Jill Doe (CX) <[email protected]>
So we want to edit the first subkey (ssb)
ssb rsa2048/56ABDJFDKFN
created: 2019-09-07 expired: 2019-09-09 usage: E
[ultimate] (1). Jill Doe (CX) <[email protected]>
When you select key (1), you should see the * next to it such as ssb*. Then you can set the expiration and then save.
gpg> key 1
sec rsa2048/AF4RGH94ADC84
created: 2019-09-07 expires: 2020-11-15 usage: SC
trust: ultimate validity: ultimate
ssb* rsa2048/56ABDJFDKFN
created: 2019-09-07 expired: 2019-09-09 usage: E
[ultimate] (1). Jill Doe (CX) <[email protected]>
gpg> expire
...
Changing expiration time for a subkey.
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 2y
Key expires at Wed 9 Sep 16:20:33 2021 GMT
Is this correct? (y/N) y
sec rsa2048/AF4RGH94ADC84
created: 2019-09-07 expires: 2020-11-15 usage: SC
trust: ultimate validity: ultimate
ssb* rsa2048/56ABDJFDKFN
created: 2019-09-07 expires: 2021-09-09 usage: E
[ultimate] (1). Jill Doe (CX) <[email protected]>
...
gpg> save
Don't forget to save the changes before quitting!
| How to renew an expired encryption subkey with gpg |
1,424,003,876,000 |
I am trying to install Pass: the standard Unix password manager, however, when I try to add passwords to the appliation I get these errors
gpg: Kelly's Passwords: skipped: No public key
gpg: [stdin]: encryption failed: No public key
GPG Public Keys?
When I type in the command gpg --list-keys I get:
/home/khays/.gnupg/pubring.gpg
------------------------------
pub 2048R/64290B2D 2012-11-05
uid Kelly Hays <[email protected]>
sub 2048R/0DF57DA8 2012-11-05
I am a little lost of how to remedy this, any ideas?
|
How did you create the password store? pass init "Kelly's Passwords"? If so, this is wrong, you should have called pass init 64290B2D.
And if then pass insert foo will fail with:
gpg: fooo: skipped: public key not found
gpg: [stdin]: encryption failed: public key not found
then you have to trust your own key first (gpg --edit-key 64290B2D, trust, 5, save).
| I try to add passwords to the "pass" password manager. But my attempts fail with "no public key" GPG errors. Why? |
1,424,003,876,000 |
When I run gpg --list-keys I get the following output:
/home/yax/.gnupg/pubring.kbx
----------------------------
pub rsa2048 2020-10-09 [SC]
4424C645C99A4C29E540C26AAD7DB850AD9CFFAB
uid [ultimate] yaxley peaks <[email protected]>
sub rsa2048 2020-10-09 [E]
What is my actual key in this block of text?
How do I get my key id?
What does the [SC] and the [E] mean, and what does sub mean?
Here's some info regarding the key.
it was generated with gpg --full-generate-key and I chose the rsa rsa option.
It's 2048 bytes long
|
what is my actual key in this block of text?
It's not shown. Since this is, as you (correctly) said, an RSA 2048-bit key, your actual public key (which is what --list-keys shows) in hex would be over 500 characters -- about 7 full lines on a typical terminal. Your private key, which, for historical reasons*, PGP and GPG call 'secret' and which is shown by --list-secret-keys, would be even longer; in addition, showing it on a terminal where in some cases a bad person might be able to get a copy of it is extremely bad for security.
How do i get my key id?
4424C645C99A4C29E540C26AAD7DB850AD9CFFAB is the fingerprint. There are two keyids, and except for v3 keys which are long obsolete, both are derived from the fingerprint. The 'short' keyid is the low 32 bits, or last 8 hex digits, of the fingerprint and thus is AD9CFFAB. The 'long' keyid is the low 64 bits, or last 16 hex digits, of the fingerprint and thus is AD7DB850AD9CFFAB. Historically the short keyid was used for almost everything, and most websites, blogs, and much documentation that you find will use and show them, but in the last few years short keyids have been successfully attacked so modern programs now default to either the long keyid or (as here) the fingerprint, but you can add them by specifying --keyid-format=long or --keyid-format=short or the equivalent option in some config file, probably .gnupg/config .
The 2048R/0B2B9B37 you found somewhere is an example of the format used by old versions of GPG. It used a single letter R for RSA, because in the old days there were really one three types of keys (and algorithms) to distinguish while now there are more; and it used the short keyid of 8 hexits.
* I originally wrote hysterical raisins in reference to the ancient times when hackers were good and computer users were intelligent, but this is no longer the case. Noted and proposed by https://unix.stackexchange.com/users/424473/yaxley-peaks which I have partially overridden.
| help understanding gpg --list--keys output |
1,424,003,876,000 | ERROR: type should be string, got "\nhttps://sks-keyservers.net/ (Internet Archive snapshot) says\n\nThis service is deprecated. This means it is no longer maintained, and new HKPS certificates will not be issued. Service reliability should not be expected.\nUpdate 2021-06-21: Due to even more GDPR takedown requests, the DNS records for the pool will no longer be provided at all.\n\nWhich keyservers can I use for gpg --keyserver \"$keyserver1\" --recv-key keyid that I can expect not will go away anytime soon?\n" |
I chose to use
pgp.surf.nl
keyserver.bazon.ru
agora.cenditel.gob.ve
pgp.benny-baumann.de
| sks-keyservers gone. What to use instead? |
1,424,003,876,000 |
I'm trying to fetch some GPG keys over keys.gnupg.net and hkps.pool.sks-keyservers.net and both fails with:
gpg: requesting key 1F41B907 from hkps server hkps.pool.sks-keyservers.net
gpgkeys: HTTP fetch error 1: unsupported protocol
I'm using Debian testing. gpg --version yields gpg (GnuPG) 1.4.16
|
For some reason or another I need to install the gnupg-curl to get SSL support over HKP:
This package contains the keyserver helper tools built with libcurl,
which replace the ones in the gnupg package built with the "curl shim"
variant of gnupg. This package provides support for HKPS keyservers.
Installing it solved the issue.
| I fail to fetch GPG keys over HKPS with "gpgkeys: HTTP fetch error 1: unsupported protocol" error |
1,424,003,876,000 |
The cryptographic signature of an RPM can be verified with the rpm -K command. This returns a string containing gpg (or pgp) and ending in OK if the signature is in RPM's database and is valid.
If the package is not signed but the checksums are valid, you'll still get OK, but no gpg.
If the package is signed but the key is missing from the RPM database, you get (GPG) (capital letters) and NOT OKAY, followed by (MISSING KEYS: GPG#deadbeef).
That's handy if I want to figure out what key I should find to install to make my package installation work.
But what if I want to verify which of several keys in my RPM keyring was used to sign a given package?
|
rpm -qa --qf '%{NAME}-%{VERSION}-%{RELEASE} %{SIGPGP:pgpsig} %{SIGGPG:pgpsig}\n'
| How do I tell which GPG key an RPM package was signed with? |
1,424,003,876,000 |
I am running Gentoo Hardened with kernel 4.1.7-hardened-r1 and I am trying to encrypt a file using GPG from a shell session opened from SSH and with the DISPLAY variable disabled in order to use pinentry-curses for password prompt. Using gpg -o file.gpg --symmetric file I can encrypt just fine. Using pv file | gpg -o file.gpg --symmetric I get the following error message:
gpg-agent[30745]: command get_passphrase failed: Inappropriate ioctl for device
|
You should set the GPG_TTY environment variable for it to work, as in this document:
GPG_TTY=$(tty)
export GPG_TTY
Those two lines are supposed to be in your ~/.bashrc (assuming bash), so they're run every time you open new terminal session.
There's another solution, though: in bash you can run your pv and pretend it's a file, using process substitution:
gpg -o file.gpg --symmetric <(pv file)
As such, it might not be a good idea to pipe-in things to programs that expect additional input. It can work differently than expected.
| Gentoo Linux GPG encrypts properly a file passed through parameter but throws "Inappropriate ioctl for device" when reading from standard input |
1,424,003,876,000 |
When I run gpg --with-fingerprints --with-colons keyfile.key, I get a machine parsable output on stdout containing the key fingerprint for the key inside the keyfile (which is exactly what I want), plus the following error on stderr:
gpg: WARNING: no command supplied. Trying to guess what you mean ...
So GnuPG is guessing the command correctly, but for my life I can't figure out what command it is guessing. I have tried almost all of the commands listed on the man page. I'm using GnuPG 2.2.
Does anybody know the correct command to read a key file and show information about the key?
Edit: Ideally the mechanism would be able to read the keyfile from stdin, such as
cat keyfile.key | gpg --some-command
I should have mentioned this earlier but so many commands for gpg work with stdin I didn't even consider it a relevant constraint.
|
The good folks at the [email protected] mailing list had the answer:
For versions >= 2.1.23:
cat keyfile.key | gpg --with-colons --import-options show-only --import
For versions >= 2.1.13 but < 2.1.23:
cat keyfile.key | gpg --with-colons --import-options import-show --dry-run --import
| GnuPG command to show key info from file |
1,424,003,876,000 |
I have an OpenPGP smart card key (YubiKey NEO) as well as a local secret key installed in my GnuPG keyring.
I'd like to encrypt and sign a file with my card's key, not the key in my keyring. How can I specify what key I'd like to sign with?
If my filesystem secret key id is DEADBEEF and my smartcard key is DEADBEE5, how do I sign with that key?
|
You should specify --default-key:
gpg -s --default-key DEADBEE5 input > output
and check afterwards with
gpg -d < output | head -1
From the gpg man page( --sign section):
The key to be used for signing is
chosen by default or can be set with the --local-user and
--default-key options.
| Encrypt and sign with specific secret key |
1,424,003,876,000 |
Upon executing apt-key list, I see a key which I wish to remove.
...
pub rsa2048 2017-11-24 [SC]
3241 413F 3CE0 B919 E82F DCA0 6239 92CF C9A9 7C2C
uid [ unknown] John Doe <[email protected]>
sub rsa2048 2017-11-24 [E]
...
man apt-key tells me that I may delete a key by executing apt-key del keyid. It also tells me that list (aka finger) will list trusted keys with fingerprints, so I am assuming that 3241 413F 3CE0 B919 E82F DCA0 6239 92CF C9A9 7C2C is the fingerprint and not the keyid. I've messed around with gpg --list-keys and gpg --list-public-keys, however, it doesn't list any keys but creates ~/.gnupg/ with various non-text files which do not display the key IDs.
How can I identify the keyid so I may delete the key?
PS. Before asking this question, I searched for a solution, and some recommend not using "short key ids". If I should not be deleting keys by the keyid as described by man apt-key, please provide the appropriate way.
|
The keyid is the last 8 characters of the gpg key's fingerprint, which is that long hex-code under pub
In your case it is: sudo apt-key del C9A97C2C
Reference:
How can I remove gpg key that I added using apt-key add -?
| How to identify gpg key IDs so they may be deleted |
1,424,003,876,000 |
Yes, I know it is a step into a lesser secure system, but the current setting makes it reasonable (the key is not important, but the signing has to be automatized).
Google results say this:
List the keys with a gpg --list-keys
Edit the key with a gpg --edit-key C0DEEBED....
A gpg command line console starts, there a passwd command changes the passphrase
Giving the password twice (in my case, simple enter) changes the key.
However, it doesn't work, because gpg2 simply doesn't allow an empty password.
What to do?
|
With pinentry-0.8.1 (and gnupg2-2.0.22) on Centos 7 I was able to remove the passphrase from the secret key by not specifying a new password; pinentry did whine and warn about the blank password but both the console and GTK pinentry programs had a "Take this one anyway" prompt that resulted in a password-free secret key.
On the other hand, this attempt failed as the then imported secret key is marked as unusable:
gpg --export-options export-reset-subkey-passwd --export-secret-subkeys > x
| How can I remove the passphrase from a gpg2 private key? |
1,424,003,876,000 |
When I put export GPG_TTY=$(tty) in my .zshrc and restart terminal window and execute
echo $GPG_TTY
it says not a tty.
When I source .zshrc by
source ~/.zshrc && echo $GPG_TTY
it correctly reports /dev/pts/1.
What could be that my .zshrc fails to find tty when its documentation says that .zshrc is used for interactive shell initialisation?
Here is my .zshrc contents:
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export ZSH="/home/ashar/.oh-my-zsh"
export EDITOR=nvim
export GPG_TTY=$(tty)
ZSH_THEME="powerlevel10k/powerlevel10k"
plugins=(git zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
|
tty command requires that stdin is attached to a terminal. When using Powerlevel10k, stdin is redirected from /dev/null when Instant Prompt is activated and until Zsh is fully initialized. This is explained in more detail in Powerlevel10k FAQ.
To solve this problem you can either move export GPG_TTY=$(tty) to the top of ~/.zshrc so that it executes before Instant Prompt is activated, or (better!) use export GPG_TTY=$TTY. The latter version will work anywhere and it's over 1000 times faster. TTY is a special parameter set by Zsh very early during initialization. It gives you access to the terminal even when stdin might be redirected.
| zshrc export GPG_TTY=$(tty) says not a tty |
1,424,003,876,000 |
I am trying to encrypt a file locally and I get an error. [email protected] is a placeholder for my email address, a public key exists for that in my keyring and also on key servers. My private key is located on a hardware key (Yubikey). I can decrypt previously encrypted files with no problem. Here is the error:
➜ ~ gpg -e -r [email protected] somefile.txt
gpg: error retrieving '[email protected]' via WKD: General error
gpg: [email protected]: skipped: General error
gpg: somefile.txt encryption failed: General error
What does this error mean and how can I solve it?
P.S. There is only one more thing that might be related. My public key is expired.
|
Extending key expiration date fixed the problem. The error message was misleading. However adding -vv as Jens Erat suggested produced some useful error messages such as gpg: Note: signature key ... expired and gpg: ... skipped: Unusable public key that helped finding the actual error.
| gpg: error retrieving '[email protected]' via WKD |
1,424,003,876,000 |
On Fedora 22, gpg doesn't find gpg-agent:
% gpg-agent --daemon
% gpg -vvv --use-agent --no-tty --decrypt file.gpg
gpg: using character set `utf-8'
:pubkey enc packet: version 3, algo 1, keyid 3060B8F7271AFBAF
data: [4094 bits]
gpg: public key is 271AFBAF
gpg: using subkey 271AFBAF instead of primary key 50EA64D5
gpg: using subkey 271AFBAF instead of primary key 50EA64D5
gpg: gpg-agent is not available in this session
gpg: Sorry, no terminal at all requested - can't get input
|
Looking at the versions reveals the problem:
% gpg-agent --version
gpg-agent (GnuPG) 2.1.7
% gpg --version
gpg (GnuPG) 1.4.19
The components come from different packages (gnupg2-2.1.7-1.fc22.x86_64 and
gnupg-1.4.19-2.fc22.x86_64 in my case). The solution is to use the gpg2
command instead of gpg.
| How to make gpg find gpg-agent |
1,424,003,876,000 |
AFAIK The basic concept about gpg/pgp is that for two people who want to create trust between them is both publish a public key and private key (the private key is kept with the user who creates it, doesn't share) with strength (1024 bits at one time, 4096 now and 8192 in future and so on and on).
Now the two of them need to publish their public keys to a keyserver (similar to a phone directory) and give a link to the keyserver where those keys are published.
Now if I go to a server say https://pgp.mit.edu/ and search for ashish I will need many ones
https://pgp.mit.edu/pks/lookup?op=get&search=ashish&op=index
Let's say the Ashish I want is this one DAD95197 (just an example) how would I import that public key ?
I did try
└─[$] gpg --keyserver pgp.mit.edu --recv-keys DAD95197
gpg: keyserver receive failed: No keyserver available
but as can be seen that didn't work.
|
gpg --keyserver pgp.mit.edu --recv-keys DAD95197
is supposed to import keys matching DAD95197 from the MIT keyserver. However the MIT keyserver often has availability issues so it’s safer to configure another keyserver.
I generally use the SKS pools; here are their results when looking for “ashish”. To import the key from there, run
gpg --keyserver pool.sks-keyservers.net --recv-keys FBF1FC87DAD95197
(never use the short key ids, they can easily be spoofed).
This answer explains how to configure your GnuPG installation to always use the SKS pools.
| How to import keys from a keyserver using gpg in debian? |
1,424,003,876,000 |
I'm trying to set up OfflineIMAP to authenticate via a gpg encrypted file (that way I can consolidate all my encryption to my gpg-agent process).
From the documentation, it seems the only way to encrypt one's server passwords is to use gnome-keyring (which I'd prefer not to run on my headless server). Is there a way to pipe in my password from a gpg file the way you can with mutt?
I know you can add extra features to offlineimap with the extension python file, but I'm afraid I wouldn't know where to start with that.
|
Another method of leaving offlineimap running with knowledge of your password, but without putting the password on disk, is to leave offlineimap running in tmux/screen with the autorefresh setting enabled in your ~/.offlineimaprc
You need to add autorefresh = 10 to the [Account X] section of the offlineimaprc file, to get it to check every 10 minutes. Also delete any config line with password or passwordeval.
Then run offlineimap - it will ask for your password and cache it in memory. It will not exit after the first run, but will sleep for 10 minutes. Then it will wake up and run again, but it will still remember your password.
So you can leave a tmux session running with offlineimap, enter your password once, and offlineimap will be fine there after.
| Encrypt OfflineIMAP Password |
1,424,003,876,000 |
Using Debian Jessie and GnuPG 2, each time I try to use GnuPG 2 (gpg2) or gpg-connect-agent together with an OpenPGP smartcard (in my case a YubiKey), the operation fails with a message
$ gpg-connect-agent --hex "scd apdu 00 f1 00 00" /bye
ERR 67108983 No SmartCard daemon <GPG Agent>
$ gpg2 --card-status
ERR 67108983 No SmartCard daemon <GPG Agent>
When using the legacy GnuPG 1 (gpg), everything works fine.
What's going wrong here?
|
scdaemon is missing
GnuPG 2 connects to the card through gpg-agent, which again does not include smart card capabilities, but accesses them through another application. This can be configured and has a system-dependent default, from man gpg-agent:
--scdaemon-program filename
Use program filename as the Smartcard daemon. The default is
installation dependent and can be shown with the gpgconf command.
Doing so reveals GnuPG tries to run /usr/lib/gnupg2/scdaemon:
$ gpgconf
gpg:GPG für OpenPGP:/usr/bin/gpg2
gpg-agent:GPG Agent:/usr/bin/gpg-agent
scdaemon:Smartcard Daemon:/usr/lib/gnupg2/scdaemon
[snip]
But this is not available:
$ /usr/lib/gnupg2/scdaemon
bash: /usr/lib/gnupg2/scdaemon2: No such file or directory
Installing scdaemon
A quick query through apt-cache reveals that Debian pulled the scdaemon out of the gnupg2 package, likely because it introduces a bunch of new dependencies GnuPG otherwise wouldn't have:
Package: scdaemon
Source: gnupg2
Version: 2.1.10-3
Installed-Size: 538
Maintainer: Debian GnuPG Maintainers <[email protected]>
Architecture: amd64
Replaces: gpgsm (<< 2.0.18-2)
Depends: gnupg-agent (= 2.1.10-3), libassuan0 (>= 2.2.0), libc6 (>= 2.15),
libgcrypt20 (>= 1.6.1), libgpg-error0 (>= 1.14), libksba8 (>= 1.2.0),
libnpth0 (>= 0.90), libusb-0.1-4 (>= 2:0.1.12)
Breaks: gpgsm (<< 2.0.18-2)
Description-en: GNU privacy guard - smart card support
GnuPG is GNU's tool for secure communication and data storage.
It can be used to encrypt data and to create digital signatures.
It includes an advanced key management facility and is compliant
with the proposed OpenPGP Internet standard as described in RFC4880.
.
This package contains the smart card program scdaemon, which is used
by gnupg-agent to access OpenPGP smart cards.
Installing it with sudo apt-get install scdaemon resolves the issue.
| Why do GnuPG 2 and gpg-connect-agent fail with "ERR 67108983 No SmartCard daemon"? |
1,424,003,876,000 |
The very first time that I install a package from epel, I am prompted if I want to import a GPG key.
Notice how there are 2 'Is this ok' prompts when installing redis?
[root@us-devops-build02 yum.repos.d]# yum install redis
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
.. truncated for readability
Total download size: 213 k
Installed size: 668 k
Is this ok [y/N]: y
Downloading Packages:
redis-2.4.10-1.el6.x86_64.rpm | 213 kB 00:00
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
Retrieving key from http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
Importing GPG key 0x0608B895:
Userid: "EPEL (6) <[email protected]>"
From : http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
Is this ok [y/N]: y
This causes puppet to fail on freshly-provisioned machines, unless I ssh in to the machine first and manually accept the installation of this key.
Why does epel need a key to be downloaded on the first installation of a package?
How can I automatically install this key on my images so puppet won't fail?
|
The reason yum is asking for a key is that it is not present in /etc/pki/rpm-gpg
ls /etc/pki/rpm-gpg/ | column
RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Security-6 RPM-GPG-KEY-CentOS-Debug-6
RPM-GPG-KEY-CentOS-Testing-6 RPM-GPG-KEY-puppetlabs
You can import the key in one of 4 ways:
use rpm --import http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-6
(as suggested by slm)
Install a package and then wait for the prompt (like I was doing)
Use the RPM package provided by epel, it installs the repo and the key simultaneously.
sudo yum -y install http://mirror.pnl.gov/epel/6/i386/epel-release-6-8.noarch.rpm"
Manually copy the key to the right directory.
| How to automatically accept epel gpg key |
1,424,003,876,000 |
Is it posible to configure gpg in a way that I enter passphrase only once, and it will work for the whole session (I'm using Ubuntu/XFce)?
I'm not sure how gpg works, it seems that the default function is that gpg asks gpg-agent for the passphrase and the agent runs pin-entry to ask for passphrase.
I would like to use pinentry-curses only once per session, so I can paste my passphrase (I have hex string from a sentence - I use echo -n <SENTENCE> | str-hex) and sign email from Claws Mail without putting passphrase (you can't use pinentry-curses with Claws Mail).
|
You can use the technique described on this page:
http://fvue.nl/wiki/Debian_4.0:_Installing_gpg-agent
Here's the gist:
Install gpg-agent and pinentry program:
sudo apt-get install gnupg-agent pinentry-curses
Add the lines below to ~/.profile. Any POSIX-confirming shell should include this file.
# Invoke GnuPG-Agent the first time we login.
# Does `~/.gpg-agent-info' exist and points to gpg-agent process accepting signals?
if test -f $HOME/.gpg-agent-info && \
kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null; then
GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info | cut -c 16-`
else
# No, gpg-agent not available; start gpg-agent
eval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`
fi
export GPG_TTY=`tty`
export GPG_AGENT_INFO
This little script will be activated when you login. If the agent is not running, it will be started. When the agent is started, it shows how to set environment variables in order to connect to it. The script saves these values in ~/.gpg-agent-info, so that when you start another login session the script can setup the variables correctly and thus use the agent.
You will only have to enter your passphrase once per boot. The agent will store your keys in memory, so you don't have to enter the passphrase again.
| How to configure gpg to enter passphrase only once per session |
1,424,003,876,000 |
I am tasked with automating a gpg decryption using cron (or any Ubuntu Server compatible job scheduling tool). Since it has to be automated I used --passphrase but it ends up in the shell history so it is visible in the process list.
How can I go about automating decryption while maintaining good (preferably great) security standards?
An example will be highly appreciated.
|
Store the passphrase in a file which is only readable by the cron job’s user, and use the --passphrase-file option to tell gpg to read the passphrase there.
This will ensure that the passphrase isn’t visible in process information in memory. The level of security will be determined by the level of access to the file storing the passphrase (as well as the level of access to the file containing the key), including anywhere its contents end up copied to (so take care with backups), and off-line accessibility (pulling the disk out of the server). Whether this level of security is sufficient will depend on your access controls to the server holding the file, physically and in software, and on the scenarios you’re trying to mitigate.
If you want great security standards, you need to use a hardware security module instead of storing your key (and passphrase) locally. This won’t prevent the key from being used in situ, but it will prevent it from being copied and used elsewhere.
| How can I automate gpg decryption which uses a passphrase while keeping it secret? |
1,424,003,876,000 |
Yesterday, I received signature expired:
Err:24 https://repo.skype.com/deb stable InRelease
The following signatures were invalid: EXPKEYSIG 1F3045A5DF7587C3 Skype Linux Client Repository <[email protected]>
Today the same problem, solutions?
I'm on Linux Mint 20.1.
|
The solution is pretty simple, Microsoft keeps their updated GPG signing key in this file: https://repo.skype.com/data/SKYPE-GPG-KEY
So, one can do for example:
curl -s https://repo.skype.com/data/SKYPE-GPG-KEY | sudo apt-key add -
Note: You should not implicitly trust any key (or file for that matter) and inspect the file thoroughly, see this answer for more info. Credit: Stephen Kitt.
UPDATE
You should see and go about with this answer of mine instead of this simple one.
| How to update expired Skype signing key |
1,424,003,876,000 |
I am trying to run an update, I get a lot of "Hit"'s and "Ign"'s but in the end I get these errors, does anybody know what they mean and how I can fix them?
W: GPG error: http://speglar.simnet.is olivia Release: The following signatures were invalid: BADSIG 3EE67F3D0FF405B2 Clement Lefebvre (Linux Mint Package Repository v1) <[email protected]>
W: GPG error: http://speglar.simnet.is raring Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key <[email protected]>
W: GPG error: http://archive.canonical.com raring Release: The following signatures were invalid: BADSIG 40976EAF437D05B5 Ubuntu Archive Automatic Signing Key <[email protected]>
W: GPG error: http://ppa.launchpad.net raring Release: The following signatures were invalid: BADSIG 5A9A06AEF9CB8DB0 Launchpad PPA for Ubuntu Wine Team
|
As Gilles explained, most Linux repositories are signed with GPG encryption keys. apt then uses these keys to ensure the authenticity of the repositories. In order to safely use a repository, you need to add it's keys to the list that apt considers trusted.
Each necessary key needs to be downloaded from a key server which is done with this command (I am using keyserver.ubuntu.com but you can use others):
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com KEY_NAME
From man apt-key:
adv
Pass advanced options to gpg. With adv --recv-key you can download
the public key.
In your case, apt is complaining about keys 3EE67F3D0FF405B2,40976EAF437D05B5,40976EAF437D05B5 and 5A9A06AEF9CB8DB0, you can get all three of them by running:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 3EE67F3D0FF405B2 40976EAF437D05B5 40976EAF437D05B5 5A9A06AEF9CB8DB0
If all goes well you should see various lines of output including:
gpg: Total number processed: 4
gpg: imported: 4 (RSA: 1)
gpg: unchanged: 0
gpg: new signatures: 4
| Invalid signatures when running apt-get update |
1,424,003,876,000 |
I'm writing a script which creates project archives and then creates 7z archives of them to make it easier on me to save specific versions and keep encrypted backups.
After I've generated the archives and I get to the encryption phase, I'd like to encrypt the files with one call to gpg if possible, so as to only have the user input their passphrase once. Otherwise, we'd either have to cache the user's passphrase in memory (which I'd really like not to do) or have them input and confirm their passphrase for every single project that is archived (which is worse).
Is there a way to pass multiple filenames to gpg to have it encrypt all of them in one go?
If I try this:
$ gpg --cipher-algo AES256 --compression-algo BZIP2 -c project1.7z project2.7z
...I see the following error in the shell:
usage: gpg [options] --symmetric [filename]
Is there a way to do what I'm looking to accomplish?
|
Is there a way to pass multiple filenames to gpg to have it encrypt all of
them in one go?
No, there is not.
You will likely want to pass the passphrase with one of the following gpg options (the latter would be most secure choice):
--passphrase
--passphrase-file
--passphrase-fd
| Encrypt multiple files at once |
1,424,003,876,000 |
I changed the password for my gpg key. However, beforehand I've built an password store via pass with the same gpg key.
Now, whenever I query passwords, I still get asked for my old gpg password. Other applications require the new passphrase.
How can I change the passphrase for pass? Do I have to run "init" again?
|
I had the same issue; @Kusalananda is spot on - pass uses gpg2, which stores the key separately, so you have to change the passphrase for both versions.
gpg --edit-key "Your Key"
> passwd
> save
gpg2 --edit-key "Your Key"
> passwd
> save
The name of the key used by pass is stored in ~/.password-store/.gpg-id.
| How to change passphrase for pass (password manager) |
1,462,301,847,000 |
I use gpg-agent for managing both PGP e SSH identities. The agent is started with a script like this
gpg_agent_env="$XDG_CACHE_HOME/gpg-agent.env"
export GPG_TTY="$(tty)"
if ! ps -U "$USER" -o ucomm | grep -q gpg-agent; then
eval "$({gpg-agent --daemon | tee $gpg_agent_env} 2> /dev/null)"
else
source "$gpg_agent_env" 2> /dev/null
fi
which is sourced whenever I run an interactive shell.
Everything works fine with this setup but there is an issue. Let's say I:
open a terminal (launching the agent in background) and start working
after a while open a second terminal
do an action that requires entering a passphrase in the second terminal
At this point gpg-agent will start pinentry-curses prompting a passphrase but it will do this in the first terminal which results in its output mixed with whatever was running (usually a text editor) with no way to resume the program or stop pinentry (it starts using 100% cpu and I have to kill it).
I must be doing something wrong here. Anyone has experienced this?
Update:
I figured out this happens only for a prompt to unlock an SSH key, which looks like this,
while prompts for PGP keys always open on the correct (i.e. current) tty.
|
As per the upstream bug against openssh, the proper way to this is adding the following to your ~/.ssh/config:
Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"
This has worked for me perfectly so far.
| How to get pinentry-curses to start on the correct tty? |
1,462,301,847,000 |
I'm trying to patch an issue in puppetlabs-apt to enable the use of key fingerprints as identifiers to ensure that a certain key is present by its 40-digit key fingerprint.
I'm having difficulty checking that the key is present and I need a command which will output the following:
The 8-digit ID of the key.
The 16-digit ID of the key.
The 40-digit ID of the key.
Is there an apt-key command I can use to output these values, one per line, so I can parse the output and check if the key is present?
|
apt-key adv will let you directly pass options to GnuPG.
So you can do something like this to get parseable outpout:
# apt-key adv --list-public-keys --with-fingerprint --with-colons
⋮
fpr:::::::::126C0D24BD8A2942CC7DF8AC7638D0442B90D010:
pub:-:4096:1:9D6D8F6BC857C906:2014-11-21:2022-11-19::-:Debian Security Archive Automatic Signing Key (8/jessie) <[email protected]>::scSC:
fpr:::::::::D21169141CECD440F2EB8DDA9D6D8F6BC857C906:
⋮
Since you're only interested in the fingerprint (the 8-digit and 16-digit IDs are just the end of the fingerprint), | grep ^fpr would seem to give you the lines you care about.
| Get apt's key ids and fingerprints in machine-readable format |
1,462,301,847,000 |
I have installed gpg version 2.2.17 from source.
When I run gpg --card-status gpg reports:
gpg: WARNING: server 'gpg-agent' is older than us (2.2.4 < 2.2.17).
gpg: Note: Outdated servers may lack important security fixes.
gpg: Note: Use the command "gpgconf --kill all" to restart them.
I have tried running the gpgconf command that was suggested but the problem persists. I have also tried uninstalling gpg2 from the Ubuntu repositories using sudo apt remove gpg2 and then rerunning gpgconf --kill all to no avail.
For good measure I even tried restarting my computer to kill the old version of gpg-agent.
Additionally, gpg-agent --version reports:
gpg-agent (GnuPG) 2.2.17
libgcrypt 1.8.4
Copyright (C) 2019 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.
|
Thanks to Kusalananda for helping me find my problem.
The issue was that gpg-agent was still installed through apt. Running sudo apt remove gpg-agent followed by gpgconf --kill all fixed the issue.
| "gpg-agent is older than us" warning message even after running gpgconf --kill all [closed] |
1,462,301,847,000 |
I have a file secret.asc containing an ASCII-armored (i.e., plain text and starts with -----BEGIN PGP PRIVATE KEY BLOCK-----) PGP/GPG secret/private key, and I would like to know its 40-character key fingerprint without importing it into my GPG keyring. Unfortunately, not a single command I've tried has surrendered that information to me.
What I've Tried
The following failed attempts were run on Ubuntu Xenial 16.04.5 with gpg version 1.4.20 and gpg2 version 2.1.11. The key in question was created solely for experimentation purposes and won't be used in anything, so I don't care if the output reveals too much about it.
$ gpg --with-fingerprint secret.asc
sec 2048R/161722B3 2018-09-12
uid Testing <[email protected]>
Short key ID only, no fingerprint.
$ gpg2 --with-fingerprint secret.asc
gpg: DBG: FIXME: merging secret key blocks is not anymore available
gpg: DBG: FIXME: No way to print secret key packets here
Error.
$ gpg --with-fingerprint --no-default-keyring --secret-keyring ./secret.asc --list-secret-keys
gpg: [don't know]: invalid packet (ctb=2d)
gpg: keydb_search_first failed: invalid packet
Error.
$ gpg2 --with-fingerprint --no-default-keyring --secret-keyring ./secret.asc --list-secret-keys
/home/jwodder/.gnupg/pubring.gpg
--------------------------------
...
This lists the secret keys in my keyring for some reason.
$ gpg --dry-run --import -vvvv secret.asc
gpg: using character set `utf-8'
gpg: armor: BEGIN PGP PRIVATE KEY BLOCK
gpg: armor header: Version: GnuPG v1
:secret key packet:
version 4, algo 1, created 1536783228, expires 0
skey[0]: [2048 bits]
skey[1]: [17 bits]
skey[2]: [2047 bits]
skey[3]: [1024 bits]
skey[4]: [1024 bits]
skey[5]: [1021 bits]
checksum: 386f
keyid: 07C0845B161722B3
:signature packet: algo 1, keyid 07C0845B161722B3
version 4, created 1536783228, md5len 0, sigclass 0x1f
digest algo 2, begin of digest b6 12
hashed subpkt 2 len 4 (sig created 2018-09-12)
hashed subpkt 12 len 22 (revocation key: c=80 a=1 f=9F3C2033494B382BEF691BB403BB6744793721A3)
hashed subpkt 7 len 1 (not revocable)
subpkt 16 len 8 (issuer key ID 07C0845B161722B3)
data: [2048 bits]
:user ID packet: "Testing <[email protected]>"
:signature packet: algo 1, keyid 07C0845B161722B3
version 4, created 1536783228, md5len 0, sigclass 0x13
digest algo 2, begin of digest 33 ee
hashed subpkt 2 len 4 (sig created 2018-09-12)
hashed subpkt 27 len 1 (key flags: 03)
hashed subpkt 9 len 4 (key expires after 32d3h46m)
hashed subpkt 11 len 5 (pref-sym-algos: 9 8 7 3 2)
hashed subpkt 21 len 5 (pref-hash-algos: 8 2 9 10 11)
hashed subpkt 22 len 3 (pref-zip-algos: 2 3 1)
hashed subpkt 30 len 1 (features: 01)
hashed subpkt 23 len 1 (key server preferences: 80)
subpkt 16 len 8 (issuer key ID 07C0845B161722B3)
data: [2046 bits]
gpg: sec 2048R/161722B3 2018-09-12 Testing <[email protected]>
gpg: key 161722B3: secret key imported
gpg: pub 2048R/161722B3 2018-09-12 Testing <[email protected]>
gpg: writing to `/home/jwodder/.gnupg/pubring.gpg'
gpg: using PGP trust model
gpg: key 793721A3: accepted as trusted key
gpg: key 161722B3: public key "[User ID not found]" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
gpg: secret keys read: 1
gpg: secret keys imported: 1
The only fingerprint to be found is that of the revocation key.
$ gpg2 --dry-run --import -vvvv secret.asc
Same output as above.
$ gpg --list-packets secret.asc
$ gpg2 --list-packets secret.asc
Basically the same output as the --dry-run --import -vvvv commands, only without the gpg: lines.
|
As indicated in the comments, the simplest solution appears to be to first dearmor the key and then run --list-secret-keys on the new file:
$ gpg --dearmor secret.asc # Creates secret.asc.gpg
$ gpg --with-fingerprint --no-default-keyring --secret-keyring ./secret.asc.gpg --list-secret-keys
Annoyingly, although the dearmored key can be written to stdout with the -o - option, neither --secret-keyring - nor --secret-keyring /dev/stdin will allow the second command to read the key from stdin, so combining the two commands into one with a pipe isn't an option. Also, running the second command with gpg2 instead of gpg still fails to give the desired output.
A slightly more elaborate approach, but one that seems to work with both versions of gpg, is to import the secret key into a temporary GPG home directory and then list the temp home's private keys:
$ mkdir -m 0700 tmphome
$ gpg --homedir tmphome --import secret.asc
$ gpg --homedir tmphome --with-fingerprint --list-secret-keys
| How do I get the fingerprint of an ASCII-armored PGP secret key with gpg? |
1,462,301,847,000 |
1) How do I know which servers are used to search for keys with gpg
gpg --search-key <keyword>
2) How to add a server to the list of queried server?
|
“Reputable” key servers exchange key updates with others, so using one is the same as using another (with slight delays in some cases). In the past, the recommendation was to use the SKS server pool, ideally using a secure connection; see the previous link for details, or this answer. However the pool has been disabled.
As of GPG 2.3.2 the default is to use keyserver.ubuntu.com; to do that with older releases, use:
gpg --keyserver keyserver.ubuntu.com --search-key ...
If you’re using that version or a later one, and you haven’t changed its default configuration, you’re good to go without specifying a key server manually.
If necessary, you can store the keyserver setting permanently by adding the relevant option to ~/.gnupg/dirmngr.conf (you may need to run gpgconf --reload dirmngr if the dirmngr daemon is already running):
keyserver hkps://keyserver.ubuntu.com
You can specify multiple keyserver options in that file, but I get the impression that only the last one is taken into account.
To actually answer your initial question, at least version 2.1 of GPG shows the key server used for a query:
$ gpg --search-key A36B494F
gpg: data source: https://host-37-191-236-118.lynet.no:443
...
| GPG key server for key search? |
1,462,301,847,000 |
One can import a key with:
rpm --import /path/to/key
But how can you tell later if you have already imported this key? Trying to reimport it will fail with an error and I am trying to avoid this as I am using Puppet to install the key.
|
You can double check if a key is already imported using rpm -qi gpg-pubkey-<version>-<release>. If it is installed, rpm will give you all the information about it, if not, it'll just exit with a return value of 1, so you could add to your puppet recipe an unless parameter:
exec { "rpm --import /path/to/package":
# ...
unless => "rpm -qi gpg-pubkey-<version>-<release> > /dev/null 2>&1"
}
| How can I verify that a PGP key is imported into RPM? |
1,462,301,847,000 |
When I tried to upgrade a Fedora 26 Server earlier today, I got this error message after downloading packages:
warning: /var/cache/dnf/forensics-5e8452ee3a114fbe/packages/protobuf-c-1.3.0-1.fc26.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 87e360b8: NOKEY
Importing GPG key 0x87E360B8:
Userid : "CERT Forensics Operations and Investivations Team <[email protected]>"
Fingerprint: 26A0 829D 5C01 FC51 C304 9037 E97F 3E0A 87E3 60B8
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-cert-forensics-2018-04-07
Is this ok [y/N]: n
Didn't install any keys
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: GPG check FAILED
So I aborted the upgrade, and I tried to dnf clean packages and redownload, but I still got the same error.
It seems that the protobuf packaged does not have a valid signature so dnf cannot continue, is that correct?
|
But... you are saying "No":
Is this ok [y/N]: n
...when asked to install the key!
Try with yes (y) instead!
| Error: GPG check FAILED when upgrading system using dnf in Fedora |
1,462,301,847,000 |
I need to encrypt a large file using gpg. Is it possible to show a progress bar like when using the pv command?
|
progress can do this for you — not quite a progress bar, but it will show progress (as a percentage) and the current file being processed (when multiple files are processed):
gpg ... &
progress -mp $!
| How to show progress with GPG for large files? |
1,462,301,847,000 |
From what little I know, in openpgp you have a private key which you keep locked or hidden somewhere and a public key which you can freely share with anybody.
Now I have seen many people attaching .asc file. If I click on that, it reveals the other person's public key.
Is having an .asc file nothing but using the putting your public key and then renaming it as something like signature.asc or is something else involved as well ? The .asc file seems to be an archive file (like a .rar or zip file)
$ cat shirish-public-key.txt
-----BEGIN PGP SIGNATURE-----
publickeystring$
-----END PGP SIGNATURE-----
How can I make/transform it into an .asc file ?
I could just do -
$ mv shirish-public-key.txt shirish.asc
but I don't know if that is the right thing to do or not.
Update - I tried but it doesn't work :(
$ gpg --armor export shirish-public-key.txt > pubkey.asc
gpg: WARNING: no command supplied. Trying to guess what you mean ...
usage: gpg [options] [filename]
Update 2 - Still it doesn't work -
$ gpg --armor --export shirish-public-key.txt > pubkey.asc
gpg: WARNING: nothing exported
seems it can't figure out that the public key is in a text file .
Update 3 -
This is what the contents of the file look like
See http://paste.debian.net/1022979/
But if I run -
$ gpg --import shirish-public-key.txt
gpg: invalid radix64 character 3A skipped
gpg: invalid radix64 character 2E skipped
gpg: invalid radix64 character 2E skipped
gpg: invalid radix64 character 2E skipped
gpg: invalid radix64 character 3A skipped
gpg: invalid radix64 character 3A skipped
gpg: invalid radix64 character 2E skipped
gpg: CRC error; 1E6A49 - B36DCC
gpg: [don't know]: invalid packet (ctb=55)
gpg: read_block: read error: Invalid packet
gpg: import from 'shirish-public-key.txt' failed: Invalid keyring
gpg: Total number processed: 0
Seems something is wrong somewhere.
FWIW gpg is version 2.2.5 from Debian testing (am running testing with all updates)
$ gpg --version
gpg (GnuPG) 2.2.5
libgcrypt 1.8.2
Copyright (C) 2018 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/shirish/.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
|
Usually, a .asc file is an ASCII-armored representation of key material (or a signature). Your shirish-public-key.txt looks like it’s just that, so if you’re sure it contains the right information you could simply rename it, as you suggest. (I doubt it contains your public key though — that should start with -----BEGIN PGP PUBLIC KEY BLOCK-----.) If a file contains “binary” data (which I’m guessing is what you mean when you say it looks like an archive), it’s not an ASCII file and wouldn’t usually be named with a .asc extension.
To export your key in this format, from your keyring rather than an existing file (thus ensuring it contains the correct data), run
gpg --armor --export YOUR_FINGERPRINT > pubkey.asc
To make things easier, files are often named by their key id; in my case:
gpg --armor --export "79D9 C58C 50D6 B5AA 65D5 30C1 7597 78A9 A36B 494F" > 0x759778A9A36B494F.asc
There are various options you can use to tweak the exported data; for example, --export-options export-minimal will strip most signatures from the key, greatly reducing its size (but also its utility for people who care about the web of trust).
| How do you generate an .asc file from pgp public key? |
1,462,301,847,000 |
I have my public key published on keyservers and now I'm on a new computer and I want to import it using the gpg command line tool. I know I can download the public key and import it using gpg --import public.key.file, however I want to know whether one can do it directly in command line using the email address.
If this is not possible what is the reason for it?
|
GnuPG has the --search, --recv-keys and --send-keys commands for interaction with key servers.
OpenPGP key servers don't validate anything, they just distribute keys. This means, anyone can upload keys with arbitrary user IDs -- just search the key server network for [email protected] -- I woulnd't expect any of those to belong to a (former or current) president of the United States.
For this reason, you can use gpg --recv-keys only with a key ID, not a user ID (and be aware short key IDs aren't any better!). There is gpg --search, though, which allows to (interactively) search the key servers on the command line -- but be aware about the security issues it implies, and make sure to validate the key after downloading (for example, by comparing the fingerprint or at least long key ID).
| How to find and add a public key to my gpg keyring from command line using email address? |
1,462,301,847,000 |
I went on to download an application today. It had it's instructions listed, step by step, number one being: adding a GPG-key with apt-key. It was followed by adding the application to apt/sources and finally downloading it with apt-get install.
I can't get my head around the need of adding a key, before downloading an application after adding the URL to sources.
Why do I need to add a GPG-key with apt-key before adding a download URL to apt/sources and downloading-installing with apt-get install?
|
Why do I need to add a GPG-key with apt-key before adding a download URL to apt/sources and downloading-installing with apt-get install?
The reason is simple: security.
First, if you don't do this, apt-get update will whine that some keys aren't found, and it downloaded "untrusted" package lists. If you do apt-get install it will ask you twice with big letters that you are installing packages from a untrusted sources. To any user this warning would be alarming (if they read them), so to prevent "How to solve 'NOPUBKEY' found" and similar questions, repository owners often include how to add their keys before even starting so users don't miss this step.
Second, if you miss this step and ignore the warning, the security is incomplete. You downloaded some packages list from a site you didn't verify. Any crack could have been exploited by someone, then tricking you into installing malicious software. If you added the keys since the start, you will have start-to-end secure transactions with the repository maintainer.
Third, when you add a key, it means that you trust that key. You say the system that you trust the person that identify themself with that key, and you want to install software from him.
| Why do I need to add a GPG-key with apt-key before adding URL to sources.list and download-installing an application with apt-get? |
1,462,301,847,000 |
I'm attempting to consolidate my encryption software to GnuPG, and I'm running into a confusing problem.
My primary unit is a headless server, and I exclusively work in tmux. There is no X session, and therefore I've configured gpg-agent to use pinentry-curses. I've configured gpg-agent to be called on login with ssh-agent emulation with this script:
if pgrep -u "${USER}" gpg-agent >/dev/null 2>&1; then
eval `cat $gnupginf`
eval `cut -d= -f1 $gnupginf | xargs echo export`
else
eval `gpg-agent -s --enable-ssh-support --daemon`
fi
I've already added my ssh key to gpg-agent, however when I attempt another ssh session the command hangs.
I've discovered that if I kill gpg-agent and create a new login shell, the agent works as it should (calling pinentry-curses then working like ssh-agent).
If, however, I create another login shell (by, say, popping open another tmux pane) and attempt to ssh, the command hangs and the pinentry-curses window is printed over the contents of the login shell that originally launched the agent.
Further, if I've closed the shell that originally launched the agent, pinentry-curses is called anyway and causes a cpu-crippling infinite loop. (Known bug, see http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=559936.)
In essence, I'd like to know what to change about my setup to make GnuPG agent work as seamlessly as ssh-agent. Thanks for any help!
|
Turns out this one was incredibly simple. Instead of using that script, I simply removed the "--agents" option from my old keychain launch script (guide here).
This causes the Keychain program to seek out both ssh-agent AND gpg-agent files. Now my encryption system does work quite seamlessly, even while relying on both types of agents.
| Best Practices for SSH, tmux & GnuPG Agent |
1,462,301,847,000 |
I need a bash script to source a file that is encrypted, as the file being sourced contains sensitive information.
I would like the script to prompt for the GPG passphrase and then run, sourcing the encrypted file. I cannot figure out how to do this though. There must be user input for the passphrase, as I don't want to store a key on the server with the encrypted file.
Looking into some different methods, I do not want to decrypt the file, source the non-encrypted file, then delete it after. I would like to reduce the chance of leaving an non-encrypted file behind, if something went wrong in the script.
Is there a way to get the GPG output of a file to source it this way? Possibly collecting STDOUT and parsing it (if GPG can even output the contents this way).
Also, if there is another way to encrypt a file that shell scripts can use, I am not aware of it, but open to other possibilities.
|
You can do this using process substitution.
. <(gpg -qd "$encrypted_filename")
Here's an example:
% cat > to-source <<< 'echo "Hello"'
% . ./to-source
Hello
% gpg -e -r [email protected] to-source
% . <(gpg -qd to-source.gpg)
Hello
gpg -d does not persist the file to disk, it just outputs it to stdout. <() uses a FIFO, which also does not result in the actual file data being written to disk.
In bash, . and source are synonyms, but . is more portable (it's part of POSIX), so I've used it here. Note, however, that <() is not as portable -- as far as I know it's only supported in bash, zsh, ksh88, and ksh93. pdksh and mksh have coprocesses which can have the same effect.
| Is there a way to source an encrypted (GPG) file on-the-fly in a script? |
1,462,301,847,000 |
I'm installing a piece of software for which I had to use a third-party repository. After adding the repository with rpm -Uvh http://[site], I installed with yum install [package]. One of the prompts that came up during installation read:
Importing GPG key 0xABCABCAB "Fname Lname <[email protected]>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-somewhere-fname
Is this ok [y/N]: y
Does anyone know where this key is stored? I'm finished with that particular repo and don't want the additional repo/key lingering unnecessarily on my machine. I've already tried gpg --list-keys as both a regular user and root, but the key isn't listed there.
As a work around would simply removing the repo also remove the key associated with it?
|
It's stored in the rpmdb, with the name of gpg-pubkey and the version as the first 8 hexadecimal characters of the fingerprint.
| When importing a key during a yum installation, where is that key stored? |
1,462,301,847,000 |
I recently generated two new subkeys to put on an external key card. I previously had a master key (usage marked SC) and a single subkey (marked E). This arrangement was worked fine for what I needed in keeping a few local files private. Just now I created two new subkeys using addkey, one signing key and one encryption key. Each of these I transfered to my card using keytocard. That seems to have worked fine and the card does what I expect.
The issue now is I can't figure out how to encrypt a file using my first subkey (key 1). No matter what I specify as a recipient or user (including the subkey id) the resulting file shows up as being encrypted against they key that's now on my card (and only on my card!).
My keyring now looks something like this:
❯❯❯ gpg --list-secret-keys
/home/caleb/.gnupg/pubring.gpg
------------------------------
sec rsa4096/75267693 2014-07-31 [expires: 2016-02-02]
uid [ultimate] Caleb Maclennan <[email protected]>
ssb rsa4096/B89B1E86 2014-07-31 [expires: 2018-07-30]
ssb> rsa2048/85BD5AD1 2015-10-06 [expires: 2016-10-05]
ssb> rsa2048/DFE6D89D 2015-10-06 [expires: 2016-10-05]
For encrypting I'm running something like this:
❯❯❯ gpg --recipient B89B1E86 -a -e test.txt
But I've tried all of --default-key, --local-user (-u), and --recipient (-r) including in combination. Any way I shake it, decrypting the result tells be it's encoded with my card key instead:
❯❯❯ gpg -d test.txt.asc
gpg: encrypted with 2048-bit RSA key, ID DFE6D89D, created 2015-10-06
"Caleb Maclennan <[email protected]>"
gpg: public key decryption failed: Card error
gpg: decryption failed: No secret key
What is the proper procedure to encrypt using a specific subkey?
|
To use specific subkeys, and not have GnuPG to resolve the subkey to a primary key, attach ! to the key. For example, to encrypt for the subkey DEADBEEF, use --recipient DEADBEEF!.
Important note: using short key IDs is not recommended due to collision attacks, instead use long key IDs or fingerprints.
| How can I encrypt with my previous GPG subkey after creating a new one? |
1,462,301,847,000 |
I can't decrypt my passwords with pass neither with
gpg directly.
gpg: encrypted with rsa4096 key, ID id, created creation_date
"name <email>"
gpg: public key decryption failed: No pinentry
gpg: decryption failed: No pinentry
It does not show a prompt dialog asking for the master password.
It says "no pinentry" but the program is installed:
$ ls /usr/bin/pinentry*
/usr/bin/pinentry
/usr/bin/pinentry-curses
/usr/bin/pinentry-emacs
/usr/bin/pinentry-gnome3
/usr/bin/pinentry-gtk-2
/usr/bin/pinentry-qt
/usr/bin/pinentry-tty
Please, I need help asap because I can't login into nothing without
my passwords, which are all encrypted with GPG.
|
I solved the problem by running the following commands
pkill gpg-agent
gpg-agent --pinentry-program=/usr/bin/pinentry-gtk-2 --daemon
and it worked. I don't know why pinentry wasn't working, but starting
a new gpg-agent daemon has worked.
| GPG can't decrypt: no pinentry program |
1,462,301,847,000 |
Is there any way to encrypt a directory using gpg? It seems to only accept files as arguments.
|
Why not tar the files to be encrypted and then encrypt the tarball?
| Encrypt directory with GnuPG? |
1,462,301,847,000 |
So I created a gpg encrypted file with password:
gpg -c passwords.txt.gpg
how can I open it with vi, edit it, then close it? (So that no passwords.txt file will be created, the decrypted passwords.txt is only in the memory! - better: after closing the passwords.txt.gpg file, the memory should be cleaned, so it shouldn't contain unencrypted passwords).
|
Original Answer
The gnupg plugin for Vim does this:
This script implements transparent editing of gpg encrypted files. The
filename must have a ".gpg", ".pgp" or ".asc" suffix. When opening
such a file the content is decrypted, when opening a new file the
script will ask for the recipients of the encrypted file. The file
content will be encrypted to all recipients before it is written. The
script turns off viminfo and swapfile to increase security.
EDIT #1
As of 2016-07-02, the original gnupg plugin is now no longer being maintained:
Due to the lack of time I'm not able to continue the development of this script. James McCoy took over development. New versions can be found at vimscript #3645.
There is however a new version:
gnupg.vim - Plugin for transparent editing of gpg encrypted files. : vim online
| How to edit a .gpg file with vi? |
1,462,301,847,000 |
The following warning message appears during my apt-get update && apt-get upgrade procedure on Linux Mint 21:
W: https://repo.skype.com/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
I searched through the Microsoft Skype download section mentioning absolutely nothing about their keys or how to manage them.
Is there a solution to this?
|
Without this being finally resolved by Microsoft, let this answer serve only as a workaround.
Maybe these commands could be chained or something, anyway... my procedure was:
Exporting the public key from the now-considered deprecated keyring:
apt-key export "D404 0146 BE39 7250 9FD5 7FC7 1F30 45A5 DF75 87C3" > skypeforlinux.asc
De-armoring the file:
gpg --dearmor < skypeforlinux.asc > skypeforlinux.gpg
Moving the GPG key file in proper place:
sudo mv skypeforlinux.gpg /usr/share/keyrings/
Editing my skype-stable.list:
sudo nano /etc/apt/sources.list.d/skype-stable.list
as follows:
deb [arch=amd64 signed-by=/usr/share/keyrings/skypeforlinux.gpg] https://repo.skype.com/deb stable main
To prevent changing this file from further updates, setting it immutable:
sudo chattr +i /etc/apt/sources.list.d/skype-stable.list
Finally, removing the GPG file from the original keyring:
sudo apt-key del "D404 0146 BE39 7250 9FD5 7FC7 1F30 45A5 DF75 87C3"
Final thoughts, as was said this is merely a workaround of a non-urgent issue, and for sure will have to be fixed by Microsoft itself in the future... And if you can do better than me, feel free to edit this answer directly. Cheers.
| repo.skype.com/deb/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION |
1,462,301,847,000 |
I was installing Manjaro GNOME 18.0.4 for my sister. However, when I tried to update all packages using pacman -Syu, the update fails due to two signature errors:
dunst package with signature by "Matti Hyttinen <[email protected]>"
notification-daemon with signature by "Brett Cornwall <[email protected]>"
Interestingly, there wasn't even anything I could have messed up, as this was the first thing I did after installation (and I reinstalled Manjaro, as it could have been a problem in installation). Additionally, it appears that both problematic packages are for notifications.
I - of course - already tried to look up the problem, and the solution I found over and over was
rm -r /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux manjaro
pacman-key --refresh-keys
as root. But this solution does not work at all in this case.
Full error message (Same with dunst):
$ sudo pacman -S notification-daemon
resolving dependencies...
looking for conflicting packages...
Packages (1) notification-daemon-3.20.0-3
Total Download Size: 0.05 MiB
Total Installed Size: 0.74 MiB
:: Proceed with installation? [Y/n]
:: Retrieving packages...
notification-daemon... 52.4 KiB 64.7K/s 00:01 [######################] 100%
(1/1) checking keys in keyring [######################] 100%
(1/1) checking package integrity [######################] 100%
error: notification-daemon: signature from "Brett Cornwall <[email protected]>" is unknown trust
:: File /var/cache/pacman/pkg/notification-daemon-3.20.0-3-x86_64.pkg.tar.xz is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n]
error: failed to commit transaction (invalid or corrupted package (PGP signature))
Errors occurred, no packages were upgraded.
Edit: I changed all SigLevel options (4 in total) in /etc/pacman.conf to SigLevel = Never, ran pacman -Syu and changed SigLevel options back. The system is now up-to-date, but the problem is still there.
|
Solution:
open /etc/pacman.conf
change all SigLevel entries to Never (comment the old ones out)
pacman -Syu
change /etc/pacman.conf back
rm -r /etc/pacman.d/gnupg
pacman-key --init
pacman-key --populate archlinux manjaro
pacman-key --refresh-keys
| Manjaro Update fails: signature is unknown trust |
1,462,301,847,000 |
In the following video: Linux HOWTO: Secure Your Data with PGP, Part 2, you are shown how to create a key pair with gpg. At about 1:50, the instructor says the following:
While the key is being generated, it is a good idea to move your mouse around a little bit to give it a bit more random number entropy for the creation of the keypair.
This seems to me like a myth, especially since command-line tools shouldn't usually be affected by the cursor. On the other hand, I have no clue how Linux's random number generator works, whether it is shared by the GUI or independent from it. Is there any stock in what he claims, or this an example of cargo cult programming?
|
There is a grain of truth to this, in fact more truth than myth, but nonetheless the statement reflects a fundamental misunderstanding of what's going on. Yes, moving the mouse while generating a key with GPG can be a good idea. Yes, moving the mouse contributes some entropy that makes random numbers random. No, moving the mouse does not make the key more secure.
All good random generators suitable for cryptography, and Linux's is in that category, have two components:
An entropy source, which is non-deterministic. The purpose of the entropy is to bootstrap the random number generator with unpredictable data. The entropy source must be non-deterministic: otherwise, an adversary could reproduce the same computation.
A pseudorandom number generator, which produces unpredictable random numbers in a deterministic fashion from a changing internal state.
Entropy has to come from a source that is external to the computer. The user is one source of entropy. What the user does is mostly not random, but the fine timing of keystrokes and mouse movements is so unpredictable as to be slightly random — not very random, but little by little, it accumulates. Other potential sources of entropy include the timing of network packets and camera or microphone white noise. Different kernel versions and configurations may use a different set of sources. Some computers have dedicated hardware RNG circuits based on radioactive decay or, less impressively, unstable electronic circuits. These dedicated sources are especially useful in embedded devices and servers which can have pretty predictable behavior on their first boot, without a user to do weird things.
Linux provides random numbers to programs via two devices: /dev/random and /dev/urandom. Reading from either device returns cryptographic-quality. Both devices use the same internal RNG state and the same algorithm to transform the state and produce random bytes. They have peculiar limitations which makes neither of them the right thing:
/dev/urandom can return predictable data if the system has not yet accumulated sufficient entropy.
/dev/random calculates the amount of available entropy and blocks if there isn't enough. This sounds good, except that the calculation is based on theoretical considerations that make the amount of available entropy decrease linearly with each output bit. Thus /dev/random tends to block very quickly.
Linux systems save the internal RNG state to disk and restore it at boot time. Therefore entropy carries over from one boot to the next. The only time when a Linux system may lack entropy is when it's freshly installed. Once there is sufficient entropy in the system, entropy does not decrease; only Linux's flawed calculation decreases. For more explanations of this consideration, read /dev/urandom is suitable to generate a cryptographic key, by a professional cryptographer. See aso Can you explain the entropy estimate used in random.c.
Moving the mouse adds more entropy to the system. But gpg can only read from /dev/random, not /dev/urandom (a way to solve this problem is to make /dev/random the same 1:9 device as /dev/urandom), so it is never at risk of receiving not-random-enough random numbers. If you don't move the mouse, the key is as random as can be; but what can happen is that gpg may get blocked in a read from /dev/random, waiting for the kernel's entropy counter to rise.
| Adding "random number entropy" for GPG keys? |
1,462,301,847,000 |
Suppose one deleted (or damaged) the following file.
/etc/apt/trustdb.gpg
How to regenerate it?
|
I found these 2 methods for doing it. The first seems like the safest way to do it.
Method #1 - using apt
$ sudo -i
$ apt-get clean
$ cd /var/lib/apt
$ mv lists lists.old
$ mkdir -p lists/partial
$ apt-get clean
$ apt-get update
Method #2 - apt-key
You can use this command to get apt-key to generate the corresponding gpg command to download the appropriate key for Canonical.
$ sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /etc/apt/secring.gpg --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: key 437D05B5: "Ubuntu Archive Automatic Signing Key <[email protected]>" 25 new signatures
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: new signatures: 25
What's happening?
You can spy a bit on the second method if you use this command:
$ sudo -i
$ bash -x apt-key update |& less
+ set -e
+ unset GREP_OPTIONS
++ mktemp
+ SECRETKEYRING=/tmp/tmp.ZhVikJSB3s
+ trap 'rm -f '\''/tmp/tmp.ZhVikJSB3s'\''' 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+ GPG_CMD='gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.ZhVikJSB3s'
++ id -u
+ '[' 0 -eq 0 ']'
++ apt-config shell TRUSTDBDIR Dir::Etc/d
+ eval 'TRUSTDBDIR='\''/etc/apt/'\'''
...
This command can also be used, as a regular user, not root!:
$ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5 Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.kZ1TEwcI5s --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com 40976EAF437D05B5
gpg: requesting key 437D05B5 from hkp server keyserver.ubuntu.com
gpg: error writing keyring `/etc/apt/trusted.gpg': file write error
gpg: key 437D05B5: "Ubuntu Archive Automatic Signing Key <[email protected]>" 26 new signatures
gpg: error reading `[stream]': file write error
gpg: Total number processed: 0
gpg: new signatures: 26
References
Fixing apt-get GPG Invalid Signature in ubuntu
Errors when updating package list with apt-get on (K)ubuntu
Apt-get Update GPG Key Errors and Fix
| How to regenerate /etc/apt/trustdb.gpg on Debian? |
1,462,301,847,000 |
The key currently has an unknown validity:
$ gpg --edit-key some.user
pub rsa4096/FAC6C35BDFF9359A
created: 2020-03-01 expires: 2022-03-01 usage: SC
trust: full validity: unknown
sub rsa4096/CDA6BEA851FFCE2E
created: 2020-03-01 expires: 2022-03-01 usage: E
[ unknown] (1). Some User <[email protected]>
The validity is calculated based on signatures. "At least one key with complete trust has to sign another key to make the key valid." Since I trust my own key ultimately, that means that if I sign Some User's key, it should also become valid.
I already signed this user's key:
$ gpg --list-signatures some.user
pub rsa4096 2020-03-01 [SC] [expires: 2022-03-01]
E9E7BDF5FB135FF9858ABAAAB007FDB2
uid [ unknown] Some User <[email protected]>
sig 3 FAC6C35BDFF9359A 2020-03-01 Some User <[email protected]>
sig 12CA169A2B5A5CFC 2020-03-15 Luc <[email protected]>
sig 3 FAC6C35BDFF9359A 2021-03-01 Some User <[email protected]>
sub rsa4096 2020-03-01 [E] [expires: 2022-03-01]
sig FAC6C35BDFF9359A 2020-03-01 Some User <[email protected]>
sig FAC6C35BDFF9359A 2021-03-01 Some User <[email protected]>
The key's expiration time was recently extended with gpg --edit-key and the expire command (by Some User themselves), but I can't re-sign it (and I can't tell whether that should even be necessary, no resource says anything about it so I guess not):
$ gpg --edit-key some.user
gpg> sign
"Some User <[email protected]>" was already signed by key 12CA169A2B5A5CFC
Nothing to sign with key 12CA169A2B5A5CFC
Checking the signatures, I see nothing out of the ordinary:
$ gpg --check-sigs some.user
pub rsa4096 2020-03-01 [SC] [expires: 2022-03-01]
E9E7BDF5FB135FF9858ABAAAB007FDB2
uid [ unknown] Some User <[email protected]>
sig!3 FAC6C35BDFF9359A 2020-03-01 Some User <[email protected]>
sig! 12CA169A2B5A5CFC 2020-03-03 Luc <[email protected]>
sig!3 FAC6C35BDFF9359A 2021-03-01 Some User <[email protected]>
sub rsa4096 2020-03-01 [E] [expires: 2022-03-01]
sig! FAC6C35BDFF9359A 2020-03-01 Some User <[email protected]>
sig! FAC6C35BDFF9359A 2021-03-01 Some User <[email protected]>
gpg: 5 good signatures
Why is this key not considered valid?
Do I need to re-sign it somehow, perhaps by revoking my old signature first?
|
Unknown validity means that GnuPG hasn’t calculated the web of trust for that key, and therefore it doesn’t know whether the key is valid or not. This is always the case for newly-added keys, but it can also happen for updated keys (since changes in signatures can affect your connection to the key). Trust recalculations don’t necessarily happen automatically, even in trivial cases, because they can be expensive and they may require user input.
Updating the trust database should fix this; you can run a minimal update with
gpg --check-trustdb
or a more complete update (which might involve answering questions about how much you trust key owners) with
gpg --update-trustdb
(The documentation says, for --check-trustdb, “Normally, GnuPG will calculate when this is required and do it automatically unless --no-auto-check-trustdb is set.” but I don’t know what the calculations are.)
| Unknown validity despite having signed the key myself |
1,462,301,847,000 |
I have a script that basically needs to do the following:
#!/bin/bash
GPG_PUBLIC_KEY=<<EOF
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.12 (GNU/Linux)
...
-----END PGP PUBLIC KEY BLOCK-----
EOF
gpg --encrypt --with-public-key "$GPG_PUBLIC_KEY" myfile.txt
Is there a way to do this without importing the GPG key to the keyring first?
|
If you don't want to use the user's keyring at all, point GPG to a temporary keyring.
tmp=
trap 'rm -rf "$tmp"' EXIT INT TERM HUP
tmp=$(mktemp -d)
export GNUPGHOME="$tmp"
gpg --import <<EOF
…
EOF
gpg -e -r … myfile.txt
If you want to use the user's keyring as well, set GNUPGHOME only during the import command and pass --keyring "$tmp/pubring.gpg" to the second gpg command.
| Is there a way to embed a GPG public key in a script without adding it to the keyring? |
1,462,301,847,000 |
I want to generate a QR code of my 4096-bit armored GPG private key. The key is so big, the program qrencode seems to fail because of its size.
$ gpg --export-secret-keys --armor > ~/private.key
$ ./qrencode -o test.png < ~/private.key
Result:
Failed to encode the input data: Numerical result out of range
How can I make that happen? Are there alternative programs to qrencode which can handle a very big GPG key? I want to print it on paper as this security.SE question suggested.
The comments of @geruetzel and @ cuonglm are addressing this version of my question.
|
Your error message already gives a hint as to what's wrong!
Your one-liner is providing the actual file content as filename to the qrencode program. Hence the error message.
Try qrencode -o test.png -t png < private.key.
You should take a look at shell input-output redirection. For example, I/O Redirection.
I see that you too have found your way to the developers GitHub repository of qrencode :) There is an explanation why a 4096-bit key cannot be encoded as a QR code:
qrencode is encoding your private GPG key as 8 bit (binary|utf-8), because the key is not pure alphanumeric. It contains special character. the alphanumeric mode only supports those special character .(%*+-./:).
So the maximum GPG key can only be 2953 char long.
From https://github.com/fukuchi/libqrencode/issues/31
| Generating QR code of very big file? |
1,462,301,847,000 |
Trying to create GPG keys which will be used for an apt repository hosted on my Centos7 box. I created a new user "apt", and then tried to create the keys, but at the very end, it states that I need a pass phrase, but then instantly closes stating cancelled by user. No it wasn't!
I have since successfully repeated these same steps root and as my standard username which happens to be in the wheels group.
Two questions:
Is it a good idea to use different gpg keys for different uses such as this apt repository, and should keys ever be created as root?
Why am I not able to create a gpg key for this user? Do I need to first create some other key for this user?
Thanks
[apt@devserver ~]$ gpg --gen-key
gpg (GnuPG) 2.0.22; Copyright (C) 2013 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Please select what kind of key you want:
(1) RSA and RSA (default)
(2) DSA and Elgamal
(3) DSA (sign only)
(4) RSA (sign only)
Your selection?
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 1y
Key expires at Thu 12 Jul 2018 04:32:05 PM UTC
Is this correct? (y/N) y
GnuPG needs to construct a user ID to identify your key.
Real name: somename
Email address: [email protected]
Comment:
You selected this USER-ID:
"somename <[email protected]>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
gpg: cancelled by user
gpg: Key generation canceled.
[apt@devserver ~]$
|
As to the "cancelled by user" error: GnuPG tries to make sure it's reading the passphrase directly from the terminal, not (e.g.) piped from stdin. To do so, it tries to open the tty directly. Unfortunately, file permissions get in the way — the tty device is owned by the user you log in as. So only that user and root can open it. GnuPG appears to report the error incorrectly, saying you canceled (when in fact it got a permission denied).
As to if you should have a separate key for the repository: yes. There are a couple of reasons that come to mind:
A repository can be maintained by more than one person. All of them will need access to the key. You obviously don't want to give them access to your personal key.
The software processing new packages will need access to the key. For many repositories, that means you have to keep the key available on an Internet-connected machine. This necessitates a lower level of security than you'd ideally have on your personal key.
If you're processing uploads automatically, you may even need to store the key with no passphrase. Obviously lowers security.
In case of compromise of your personal key, it's nice to only have to revoke that. Same with compromise of the repository key. It makes revoking a compromised key cheaper.
It's pretty normal to use your personal key to sign the repository key.
As to running key generation as root: not ideal (don't run things as root without good reason), but likely not really an issue.
| gpg: cancelled by user |
1,462,301,847,000 |
If you call GPG without input, it just says
gpg: Go ahead and type your message ...
You can enter text and everything, but how do you end the input? I've seen something like this in multiple different programs, but I've never known how.
|
You need to input EOF (End Of File). Do this with CTRL+D (or more generally, ^D).
| Finish entering text in GPG |
1,462,301,847,000 |
I just generated a new GPG key pair and gpg displays some random plus, minus, greater than, less than and circumflex signs. I was always wondering what they mean. Can you explain it to me?
iblue@nerdpol:~$ gpg --gen-key
[... snip ...]
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.........+++............<+++++>.+++++...............>..+++++..<
...+++++............>+++++<.+++++.....................<+++++..>
.................................................+++++^^^^
|
These are progress indications from the key generation process. Since key generation can be slow, you get a bit of an animated display. The details of the display are pretty obscure and not useful except (a little) for debugging some very specific part of GPG.
You're seeing an El Gamal key pair generation. GPG needs to generate several numbers with specific mathematical properties. Some of these numbers, for example prime numbers, are generated by trial and error (generate a random number in approximately the right range, test if it has the requisite properties, req). GPG print:
a newline after successfully generating a prime or generator;
< and > if a randomly generated prime is rejected for not being in the proper range;
! if a prime is rejected for not being suitable after all;
^ when trying a candidate generator;
. if a randomly generated candidate prime p turns out not to be prime and GPG tries p+2;
: if a randomly generated candidate prime turns out not to be prime and GPG tries a fresh random number;
. if a simple primality test fails;
+ if a long primality test succeeds.
If you want the detailed list, look at calls to progress in cipher/dsa.c, cipher/elgamal.c and cipher/primegen.c in the GPG source.
| GPG key pair generation: What do the plus and minus signs mean? |
1,462,301,847,000 |
I am trying to install spotify using yay on Arch linux. But when I run yay -S spotify this happens:
john@arch-thinkpad ~> yay -S spotify
:: There are 5 providers available for spotify:
:: Repository AUR
1) spotify 2) spotify-dev 3) spotify-legacy 4) spotify094 5) spotio
Enter a number (default=1): 1
:: Checking for conflicts...
:: Checking for inner conflicts...
[Repo:1] libcurl-gnutls-7.73.0-1
[Aur:1] spotify-1:1.1.42.622-2
1 spotify (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: Downloaded PKGBUILD (1/1): spotify
1 spotify (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==>
:: (1/1) Parsing SRCINFO: spotify
:: PGP keys need importing:
-> --some-key--, required by: spotify
==> Import? [Y/n] y
:: Importing keys with gpg...
gpg: keyserver receive failed: No name
problem importing keys
How can I fix this error to install package successfully ?
|
It was solved by manually adding gpg key by this command:
gpg --keyserver keyserver.ubuntu.com --recv-key <key name>
and running installation again:
yay -S spotify
| yay error: gpg: keyserver receive failed: No name |
1,462,301,847,000 |
I would like to refresh the UIDs and postpone the expiration date but I get.
gpg --edit-key [email protected]
gpg (GnuPG) 2.1.15; Copyright (C) 2016 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
pub rsa4096/0x03FFE7DE7AEFDD3B
created: 2014-09-21 expires: 2017-09-20 usage: SC
trust: ultimate validity: ultimate
ssb rsa4096/0x612502E7B5475FF9
created: 2014-09-21 expires: 2017-09-20 usage: E
ssb rsa4096/0x6777F12E17534B8E
created: 2014-09-21 expires: 2017-09-20 usage: S
[ultimate] (1). Nathan DWEK <[email protected]>
[ultimate] (2) Nathan DWEK <[email protected]>
gpg> expire
Changing expiration time for the primary key.
gpg: WARNING: no user ID has been marked as primary. This command may
cause a different user ID to become the assumed primary.
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 2y
Key expires at jeu 19 sep 2019 12:19:31 CEST
Is this correct? (y/N) y
gpg: signing failed: No secret key
gpg: make_keysig_packet failed: No secret key
However:
gpg --list-secret-keys
/home/nathdwek/.gnupg/pubring.gpg
---------------------------------
sec# rsa4096/0x03FFE7DE7AEFDD3B 2014-09-21 [SC] [expires: 2017-09-20]
Key fingerprint = 1A12 B5ED F67A 947C B616 6FCC 03FF E7DE 7AEF DD3B
uid [ultimate] Nathan DWEK <[email protected]>
uid [ultimate] Nathan DWEK <[email protected]>
ssb rsa4096/0x612502E7B5475FF9 2014-09-21 [E] [expires: 2017-09-20]
ssb rsa4096/0x6777F12E17534B8E 2014-09-21 [S] [expires: 2017-09-20]
Signing and using pass, a gpg-based password manager has been working perfectly for a long time. I am on Ubuntu 17.04 with cinnamon.
|
I was using an offline master key and used subkeys for signing and decryption.
This was displayed by the # in front of my master key.
This is why the only operations I could not perform were key signing operations.
| GPG --edit-key fails with "no secret key" even though --list-secret-keys and --sign work as expected |
1,462,301,847,000 |
Releases of gnupg from 2.1.16 (currently 2.1.17) block waiting for entropy only on first invocation.
Note: this isn't an attempt to generate a key, just to decrypt a file and start the agent.
The first time gpg-agent is started, either directly with gpg2 file.gpg or using an application like pass, pinentry appears and once I enter my passphrase and hit Enter it hangs for around 15s.
All subsequent calls, within the window of the default-cache-ttl, are executed immediately.
Running in --debug-all mode, the period where the hang occurs prints1:
gpg: DBG: chan_6 <- S PROGRESS need_entropy X 30 120
gpg: DBG: chan_6 <- S PROGRESS need_entropy X 120 120
gpg: DBG: chan_6 <- S PROGRESS need_entropy X 30 120
gpg: DBG: chan_6 <- S PROGRESS need_entropy X 120 120
gpg: DBG: chan_6 <- S PROGRESS need_entropy X 30 120
...
I installed rng-tools to supplement the entropy pool:
cat /proc/sys/kernel/random/entropy_avail
4094
and compared with a machine with the same version of gnupg that did not have rng-tools or haveged installed, that exhibits no delay:
cat /proc/sys/kernel/random/entropy_avail
3783
So there appears to be sufficient entropy in the pool. This was tested on kernels 4.8.13 and 4.9.
Does gpg use a different pool? How can I provide sufficient entropy, or otherwise eliminate the 15s delay when starting the agent?
1. The full debug log.
|
I think I know what's going on. In gnupg's agent/gpg-agent.c, this function processes messages from libgcrypt.
/* This is our callback function for gcrypt progress messages. It is
set once at startup and dispatches progress messages to the
corresponding threads of the agent. */
static void
agent_libgcrypt_progress_cb (void *data, const char *what, int printchar,
int current, int total)
{
struct progress_dispatch_s *dispatch;
npth_t mytid = npth_self ();
(void)data;
for (dispatch = progress_dispatch_list; dispatch; dispatch = dispatch->next)
if (dispatch->ctrl && dispatch->tid == mytid)
break;
if (dispatch && dispatch->cb)
dispatch->cb (dispatch->ctrl, what, printchar, current, total);
/* Libgcrypt < 1.8 does not know about nPth and thus when it reads
* from /dev/random this will block the process. To mitigate this
* problem we take a short nap when Libgcrypt tells us that it needs
* more entropy. This way other threads have chance to run. */
#if GCRYPT_VERSION_NUMBER < 0x010800 /* 1.8.0 */
if (what && !strcmp (what, "need_entropy"))
npth_usleep (100000); /* 100ms */
#endif
}
That last part with npth_usleep was added between 2.1.15 and 2.1.17. Since this is conditionally compiled if libgcrypt is older than 1.8.0, the straightforward fix would be recompiling gnupg against libgcrypt 1.8.0 or later… unfortunately that version doesn't seem to exist yet.
The weird thing is, that comment about libgcrypt reading /dev/random is not true. Stracing the agent reveals it's reading from /dev/urandom and using the new getrandom(2) syscall, without blocking. It does however send many need_entropy messages, causing npth_usleep to block. Deleting those lines fixes the issue.
I should mention that npth seems to be some kind of cooperative multitasking library, and npth_usleep is probably its way to yield, so it might be better to just significantly reduce that delay, just in case libgcrypt decides to block some day. (1ms is not noticeable)
| gnupg 2.1.16 blocks waiting for entropy |
1,462,301,847,000 |
Whenever I try to create a signed git commit, I need to enter my GPG key. It spawns some GUI application to receive the password. It looked like the application was seahorse, so I uninstalled it, but git still uses some GUI app. Polybar doesn't report the application name and it's title is just [process]@MYPC.
How do I get git to use the command line / pinentry?
Versions:
gnuPG: 2.2.19
git: 2.25.1
pinentry: 1.1.0
|
What's in your ~/.gnupg/gpg-agent.conf?
I have pinentry-program /usr/bin/pinentry-curses in mine, and everything which uses gpg will ask for my pass-phrase in the terminal.
NOTE: You will need to restart your gpg-agent (or send it a HUP signal) if you change its config. Just running gpgconf --kill gpg-agent will do, gpg will restart it when needed.
ALSO NOTE: the environment variable GPG_TTY needs to be your current tty (i.e. the tty you're currently running gpg in - or whatever calls gpg, such as mutt, pass, git, etc). So add the following to your ~/.bashrc (or whatever's appropriate for your shell):
GPG_TTY=$(tty)
export GPG_TTY
See man gpg-agent for details.
| How do I get git to use the cli rather than some GUI application when asking for GPG password? |
1,462,301,847,000 |
gpg has an option --armor, which can generate output in an ASCII-armored format similar to uuencoded documents.
It also has an option --clearsign which causes the document to be wrapped
in an ASCII-armored signature.
How are they different? Can one be done alternatively in terms of the other? Thanks.
$ cat sleep.py
#! /usr/bin/python3
import time
time.sleep( 30 )
$ gpg --clearsign sleep.py
$ cat sleep.py.asc
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
#! /usr/bin/python3
import time
time.sleep( 30 )
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEEgp775lYsDVGRz/4m1bmNWQ9vUP4FAlxYfZQACgkQ1bmNWQ9v
UP7BTgv/QphBjsW+7i4rq/o5KcooEvd4g7dWClulqvBAE55P6FaezbSQBvP+nnjb
aHiTwWPq4qQLfV3rcaxOrH95hZHiloLIaZoY4f3kVBHD6tcWpJSnyJ2cih+I3HL/
vJyVM9KCakLrtNTX/wDDGiKLg0MQk3g77SllAsmt1A/gRX+PySUHOd212NRYN/Ht
OCxe53lI9xyYT+qRiySIGHzKMCC6l0Kg0lO0qS3wB9eKWNajfmP3KvRqHN0Wraex
8fd7DjLdlPXhkBFypNfo0h8RbMUkr2+Kltb7ZUMVoJtLjH+WOacHdqX9H7FY29lA
A4aqwneriMrSlAFL2WusOJ5R9VRunbMQJRaG5tkR6YR6ZMv2diA2f/j5muXSw8+m
Vh9t0NEXPyP5eMr5xrtB3n06ciXl++vYD+p6e3Bq7QNehfZuanZMYrCSafUoLTVe
ubUTa6gUjPEw6A/wwBZwZuZC27Ivy6Skt4Iw1hfvx2eyJxhDAANaATqSZTO18zEF
nJ7H1FHU
=g9wE
-----END PGP SIGNATURE-----
$ gpg --armor --detach-sign sleep.py
$ cat sleep.py.asc3
-----BEGIN PGP SIGNATURE-----
iQGzBAABCgAdFiEEgp775lYsDVGRz/4m1bmNWQ9vUP4FAlxYfh4ACgkQ1bmNWQ9v
UP6UZQv+PrfkPbQWB4XnbDmpiWDZJC4Z6ZFf1q44uhbcT4QzeKET8VFe27ipJRXV
QR+rTOyuVpo+qE/xDBkD+SVM3sYPwZ01yaYt6CGK6YKWYacJUuZpLXnLY8R5ycTY
3EmjpJ8nt3JcWMGH3DtwEHSpvVzgVAfyIFQiHpsXJgXhqdrzR0/4eNkkf9TSzRSA
KcRQYjkmBYCfq+h6l2fuUx5lmungY5zqVR2ZKvfMYNryTmBZXMzQOHPrlNzTggXm
STcQLDqJdPJ7/3SQDQhEyi7xbl3uPdYitxKy0krS3kl25b6Zmg/RBelXRFnuVS+b
3JfNrrabhv8uN8wV62LK6Coq7Gv1eIDhtW7sZ7pHFnG9h8Q37AJZuTK3iOctfD4e
5QlBCHUbgQUbkfYLmyKQdgCCH3OSL0RtqhWXuqBP4GYSxmRp8af2XNrl/+o/gOQP
ctCSD9bWtoA74li6VzU1p3YI9Q6ilc1+GBqGL3isE39jf1hL4dtMu/iWExWgytPk
6Im1ZqrO
=TyOB
-----END PGP SIGNATURE-----
|
--armor is an output modifier: you use it in addition to other arguments which specify the operation you want gpg to perform, and it changes the output to be an ASCII-armored file instead of a binary file. Thus
gpg --armor --sign myfile
will sign myfile and output the signed file in myfile.asc, but none of the contents of myfile will be immediately visible in myfile.asc. (gpg compresses the contents by default, among other transformations.)
--clearsign is a complete operation: gpg signs the given file, and wraps the signature around the content without modifying it. Thus
gpg --clearsign myfile
will sign myfile and output the signed file in myfile.asc, in such a way that the original contents of myfile will be immediately visible in myfile.asc.
Clear-signing is ideal for signing emails or other text documents which should remain readable as-is, without involving gpg. Recipients can optionally verify the signature using gpg, but they don’t have to use gpg to read the contents.
You can approximate the result of --clearsign using --armor by producing a detached signature (gpg --armor --detach-sign myfile): if gpg doesn’t need to alter the signed content, then the detached signature will be identical to the signature block at the end of a clear-signed file. You’d need to add the appropriate header:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
or whatever is appropriate.
| gpg: --armor vs --clearsign |
1,462,301,847,000 |
On a Debian Jessie system:
$ ls -al ~/.gnupg/
total 58684
drwx------ 2 username username 4096 Nov 28 20:52 .
drwxr-xr-x 50 username username 4096 Nov 28 19:33 ..
-rw------- 1 username username 9602 Jun 24 22:47 gpg.conf
-rw-r--r-- 1 username username 18 Jun 25 21:07 .#lk0xb7f2fa50.hostname.5551
-rw-r--r-- 1 username username 18 Aug 19 19:15 .#lk0xb8e9bf48.hostname.32133
-rw-r--r-- 1 username username 18 Aug 19 19:15 .#lk0xb8e9dc48.hostname.32133
-rw-r--r-- 1 username username 18 Nov 28 20:52 .#lk0xb9387478.hostname.24497
-rw------- 1 username username 30018875 Nov 18 21:49 pubring.gpg
-rw------- 1 username username 30018875 Nov 18 20:54 pubring.gpg~
-rw------- 1 username username 600 Jun 21 21:34 random_seed
-rw------- 1 username username 4890 May 7 2015 secring.gpg
-rw------- 1 username username 1440 Nov 18 18:50 trustdb.gpg
I have replaced the actual username with username and the actual hostname with hostname.
What is the origin/purpose of the files whose names begin .#lk0xb?
|
They are (as the "lk" suggests) lock files. A comment in the gnupg sources says
This function creates a lock file in the same directory as
FILE_TO_LOCK using that name and a suffix of ".lock". Note that on
POSIX systems a temporary file ".#lk..pid[.threadid] is
used.
and also states that there is a cleanup function (to remove obsolete locks). You're seeing leftover lock-files where the cleanup function failed.
The pid and threadid do not match an earlier comment in the code (it seems that the comments are not updated). The actual code which makes the filename looks different from the comments (quoting from gnupg-1.4.19):
snprintf (h->tname, tnamelen, "%.*s/.#lk%p.", dirpartlen, dirpart, h );
h->nodename_off = strlen (h->tname);
snprintf (h->tname+h->nodename_off, tnamelen - h->nodename_off,
"%s.%d", nodename, (int)getpid ());
but of course, the code is more pertinent than the comments.
| Files starting with .#lk0xb in ~/.gnupg directory - what are they? |
1,462,301,847,000 |
I'm trying to hide the "output" of a gnupg command, but it seems that it is always printed.
the command is:
echo "thisprogramwørks" | gpg -q --status-fd 1 --no-use-agent --sign --local-user D30BDF86 --passphrase-fd 0 --output /dev/null
It is a command to verify the password of pgp keys, and by using it like this:
a=$(echo "thisprogramwørks" | gpg -q --status-fd 1 --no-use-agent --sign --local-user D30BDF86 --passphrase-fd 0 --output /dev/null)
I recover the output:
echo $a
[GNUPG:] USERID_HINT F02346C1EA445B6A p7zrecover (7zrecover craking pgp test) <a@a> [GNUPG:] NEED_PASSPHRASE F02346C1EA445B6A F02346C1EA445B6A 1 0 [GNUPG:] GOOD_PASSPHRASE [GNUPG:] BEGIN_SIGNING [GNUPG:] SIG_CREATED S 1 8 00 1435612254 8AE04850C3DA5939088BE2C8F02346C1EA445B6A
the problem is that when I use the command, the console prints:
You need a passphrase to unlock the secret key for
user: "test (test) <a@a>"
1024-bit RSA key, ID EA445B6A, created 2015-06-29
I've been trying to use command redirects like &>/dev/null and stuff like that, but passphrase text is always printed. It is possible to hide this text?
|
The "problem" is, that gpg writes directly to the TTY instead of STDOUT or STDERR. That means it cannot be redirected.
You can either use the --batch option as daniel suggested, but as a more general approach you can use the script tool, which fakes a TTY. Any output is then sent to STDOUT, so you can redirect it to /dev/null:
script -c 'echo "thisprogramwørks" | gpg -q --status-fd 1 --no-use-agent --sign --local-user D30BDF86 --passphrase-fd 0 --output /dev/null' > /dev/null
The output is also written to a file, so you can still get and analyze it. See man script (link)
| Silent GnuPG password request with bash commands |
1,424,264,793,000 |
Basically, I have an email account I can access as POP3 or IMAP. I want to take all incoming emails, encrypt them, and then forward the encrypted version to my gmail account (so I can see the subject/notifications on my phone/gmail account; and possibly decrypt the message with a passphrase -- though this last step doesn't need to be implemented initially).
I probably could write a python script to do this, but using the proper linux tools seems like a better route. I have postfix (in a satelite configuration) already set up to send outgoing mail.
What's the easiest way to read POP3/IMAP on a linux box and get it to gpg encrypt the email's body and attachments (not subject headers) with my public key, and forward it to my gmail acct?
(For the record; its against work's policy (partially for compliance with US HIPAA law) for me to send unencrypted versions of my email to my phone; as there's the potential for someone to deliberately (or inadvertantly) email protected data to my phone. Work considers GPG to be secure.)
|
I just saw the other response and guess I never wrote up the solution I actually implemented. It turns out that python imaplib is straightforward and I wrote a very quick script. Barring a few changes (e.g., anonymizing my various USERNAMEs, EMAILPASSWORD, WORKDOMAINNAME, MYGPGKEYID). I also don't just send encrypted it; but prepend the subject with the username of the sender and put some of the header stuff before the GPG (in case I'm reading it on my phone and can't decrypt).
#!/usr/bin/python
import imaplib
import email
from datetime import datetime,timedelta
import shelve
from subprocess import Popen, PIPE
def piped_call(command1, arg1_list, command2, arg2_list):
"""
if arg1_tuple = (a10, a11, a12); arg2_tuple is (a20, a21)
This executes "command1 a10 a11 a12 | command2 a20 a21 a22"
"""
if type(arg1_list) not in (list, tuple):
arg1_list = [arg1_list,]
if type(arg2_list) not in (list, tuple):
arg2_list = [arg2_list,]
p1 = Popen([command1,]+list(arg1_list), stdout=PIPE)
p2 = Popen([command2,]+list(arg2_list), stdin=p1.stdout, stdout=PIPE)
p1.stdout.close()
return p2.communicate()[0]
shlf = shelve.open('/home/USERNAME/mail/mail.shlf')
# This shelf (a persistent python dictionary written to file) has as its key
# the IMAP message ids of all emails that have been processed by this script.
# Every time the script runs, I fetch all emails from the current day
# (except from midnight to 1am, where I fetch all emails since yesterday)
# and then send all emails that haven't been sent previously
# by checking message ids against the python shelf.
M = imaplib.IMAP4_SSL(host='imap.WORKDOMAINNAME.com', port=993)
M.login('EMAILUSERNAME', 'EMAILPASSWORD')
M.select()
dt = datetime.now() - timedelta(0,5*60*60)
# Only search for messages since the day of an hour earlier.
# This way messages from yesterday don't get lost at midnight; as well as limiting the number of messages to process through to just todays.
typ, uid_data = M.uid('search', None, '(SINCE %s)' % dt.strftime('%d-%b-%Y'))
for num in uid_data[0].split():
typ, data = M.uid('fetch', num, '(RFC822)')
e = email.message_from_string(data[0][1])
print 'Message %s\n%s\n' % (num, e['subject'])
if num not in shlf:
sender_email = e['return-path']
for s in ('<', '>', '@WORKDOMAINNAME.com'):
sender_email = sender_email.replace(s,'')
subject = "%s: %s" % (sender_email, e['Subject'])
body = ("From: %s\n"
"To: %s\n"
"Cc: %s\n"
"Subject: %s\n\n" % (e['From'], e['To'], e['Cc'], e['subject']))
payload = e.get_payload()
if type(payload) in (list, tuple):
payload = str(payload[0])
else:
payload = str(payload)
encrypted_payload = piped_call('echo', (payload,),
'gpg', ('-e', '-a', '-r', 'MYGPGKEYID'))
body += encrypted_payload
piped_call('echo', (body,),
'mail', ['[email protected]', '-s', subject])
shlf[num] = datetime.now()
M.close()
M.logout()
I then added the following lines to my crontab (the script above is named mail.py inside a directory called mail), so it will run every 5 minutes during the normal hours on weekdays (M-F 8-7pm) and less frequently at other hours. (crontab -e)
# Every 5 minutes, M-F from 8am - 7pm.
*/5 8-19 * * 1-5 cd /home/USERNAME/mail && ./mail.py >> /home/USERNAME/mail/mail.log 2>&1
# Every 30 minutes, Sat&Sun from 8am-7pm
0,30 8-19 * * 6,7 cd /home/USERNAME/mail && ./mail.py >> /home/USERNAME/mail/mail.log 2>&1
# Every 30 minutes, M-F 8pm-2am; (no emails 2am-8am)
0,30 0-2,20-23 * * 1-5 cd /home/USERNAME/mail && ./mail.py >> /home/USERNAME/mail/mail.log 2>&1
# Every 60 minutes, Sat&Sun hours 8pm-2am; (no emails 2am-8am)
0 0-2,20-23 * * 6-7 cd /home/USERNAME/mail && ./mail.py >> /home/USERNAME/mail/mail.log 2>&1
| Receive Pop/IMAP email and then forward as encrypted to gmail |
1,424,264,793,000 |
I have data like this:
-----BEGIN PRIVATE KEY-----
MIIJQwIBADANBgkqhkiG9w0BAQEFAASCCS0wggkpAgEAAoICAQDPzCORz9kUh4yt
73fiG1amQ16jwjXNzNO0d4xUWlrCP3dTfXnvtF35r2N/5Nefw9CcztBUAZACbwtn
(... just sample data ...)
jSYDRr88RZI4QYv9pW0+A8vWS2SJnIPW0fP9mcPOdZXxG/V2rL03YV5xcLCdbuBu
1tunEWZ5VcjfyEDfP7qZdWjGIYselOg=
-----END PRIVATE KEY-----
If I run gpg --import it says:
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
How can I get this private key into GPG?
|
Although underlying crypto primitives are similar, PGP file (packet) formats including keys are very different from those
used by OpenSSL (mostly ASN.1 and PEM). You don't say so, but this appears to be an RSA key. If Java is okay for you, it can do that
using BCPROV plus BCPKIX (for PEM) and BCPG (for PGP) from http://www.bouncycastle.org . Adjust name etc to taste.
// nopackage
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.NoSuchProviderException;
import java.security.Security;
import java.security.SignatureException;
import java.security.spec.KeySpec;
import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.RSAPublicKeySpec;
import java.util.Date;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
import org.bouncycastle.bcpg.ArmoredOutputStream;
import org.bouncycastle.bcpg.HashAlgorithmTags;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPEncryptedData;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPSecretKey;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.operator.PGPDigestCalculator;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder;
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPKeyPair;
import org.bouncycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder;
import org.bouncycastle.openssl.PEMParser;
/**
* A simple utility class that converts PEM PKCS8 (OpenSSL) to a RSA PGPPublicKey/PGPSecretKey pair.
* <p>
* usage: UnixSE276317 [-a] identity passPhrase inputPEM
* <p>
* Where identity is the name to be associated with the public key. The keys are placed
* in the files {pub,secret}.asc if -a (armor) is specified and .bpg otherwise.
*/
//modified from package org.bouncycastle.openpgp.examples class RSAPrivateKeyGenerator
public class UnixSE276317
{
private static void exportKeyPair(
OutputStream secretOut,
OutputStream publicOut,
KeyPair pair,
String identity,
char[] passPhrase,
boolean armor)
throws IOException, InvalidKeyException, NoSuchProviderException, SignatureException, PGPException
{
if (armor)
{
secretOut = new ArmoredOutputStream(secretOut);
}
PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build().get(HashAlgorithmTags.SHA1);
PGPKeyPair keyPair = new JcaPGPKeyPair(PGPPublicKey.RSA_GENERAL, pair, new Date());
PGPSecretKey secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, keyPair, identity, sha1Calc, null, null,
new JcaPGPContentSignerBuilder(keyPair.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1),
new JcePBESecretKeyEncryptorBuilder(PGPEncryptedData.CAST5, sha1Calc).setProvider("BC").build(passPhrase));
secretKey.encode(secretOut);
secretOut.close();
if (armor)
{
publicOut = new ArmoredOutputStream(publicOut);
}
PGPPublicKey key = secretKey.getPublicKey();
key.encode(publicOut);
publicOut.close();
}
public static void main(
String[] args)
throws Exception
{
Security.addProvider(new BouncyCastleProvider());
//KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "BC");
//kpg.initialize(1024);
//KeyPair kp = kpg.generateKeyPair();
int flag = args.length > 0 && args[0].equals("-a")? 1: 0;
if (args.length != flag+3)
{
System.out.println("UnixSE276317 [-a] identity passPhrase inputPEM");
System.exit(0);
}
// adapted from org.bouncycastle.openssl.PEMParser$PrivateKeyParser+RSAKeyPairParser
FileReader rdr = new FileReader (args[flag+2]);
PrivateKeyInfo pk8 = (PrivateKeyInfo) new PEMParser(rdr).readObject();
rdr.close();
ASN1Sequence seq = (ASN1Sequence) pk8.parsePrivateKey();
org.bouncycastle.asn1.pkcs.RSAPrivateKey keyStruct = org.bouncycastle.asn1.pkcs.RSAPrivateKey.getInstance(seq);
KeyFactory fact = KeyFactory.getInstance ("RSA");
KeySpec privSpec = new PKCS8EncodedKeySpec (pk8.getEncoded());
KeySpec pubSpec = new RSAPublicKeySpec(keyStruct.getModulus(), keyStruct.getPublicExponent());
KeyPair kp = new KeyPair (fact.generatePublic(pubSpec), fact.generatePrivate(privSpec));
String[] suffix = {"bpg","asc"};
FileOutputStream out1 = new FileOutputStream("secret."+suffix[flag]);
FileOutputStream out2 = new FileOutputStream("pub."+suffix[flag]);
exportKeyPair(out1, out2, kp, args[flag+0], args[flag+1].toCharArray(), flag>0);
}
}
| How can I import a key in PEM format (not OpenPGP) into GPG? |
1,424,264,793,000 |
gpg -ca passwords.txt create encrypted ASCII file passwords.txt.asc. Emacs open the file as a normal text file:
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.19 (GNU/Linux)
jA0EAwMCkIp3+bQkLWJgyTQYLGVN8EUEG0BE42sEj/8PrnSzgviSiENxtK+/2n73
WXD7EtndVS/MX4lFJ96h8VozChUA
=zSwh
-----END PGP MESSAGE-----
How do I make Emacs auto-decrypt and encrypt the file when I open and save it?
|
I did following to let Emacs open .asc files in the same way of .gpg files
(require 'epa-file)
(epa-file-enable)
(setq epa-file-name-regexp "\\.\\(gpg\\|asc\\)$")
(epa-file-name-regexp-update)
| How to use Emacs to recognize and automatically open GPG encrypted file in ASCII armored format? |
1,424,264,793,000 |
Context
I would like to use GPG authentication subkeys instead of SSH keys.
I would also like to use gpg-agent to manage password caching for these keys.
I am running in a headless environment, so I would like to use pinentry-curses for my password entry program, but I am fine with anything that works in a headless environment.
My development workflow is such that I am working in multiple tmux sessions and panes, and need to be able to git push from any of them.
Problem
The problem occurs when I attempt to do so. Instead of pinentry popping up in my current pane, it pops up in a random other pane (or sometimes perhaps no pane at all, but it's possible there are just too many to search through). To resolve this, I need to kill that pane and pinentry-curses and even then it still fails at times.
What I've Tried
Configurations I've Tried
My current configuration is as follows, though I've tried a plethora over the past couple weeks to attempt to get this working.
# ~/.zshrc
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
fi
if [[ $SSH_AUTH_SOCK == /tmp/* ]]; then
ln -sf $SSH_AUTH_SOCK $HOME/.ssh-agent-sock
export SSH_AUTH_SOCK=$HOME/.ssh-agent-sock
fi
export GPG_TTY=$(tty)
gpg-connect-agent updatestartuptty /bye >/dev/null
# ~/.gnupg/gpg-agent.conf
pinentry-program /usr/sbin/pinentry-curses
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support
# ~/.gnupg/gpg.conf
use-agent
# ~/.gnupg/sshcontrol
MYFINGERPRINTS
# ~/.ssh/config
Host localhost
ForwardAgent yes
AddKeysToAgent ask
Links I've Tried
gpg2 pinentry fails without X
Best Practices for SSH, tmux & GnuPG Agent
Pinentry fails with gpg-agent and SSH
https://wiki.archlinux.org/index.php/GnuPG#SSH_agent
https://gist.github.com/andrewlkho/7373190
https://www.linode.com/docs/security/authentication/gpg-key-for-ssh-authentication/
https://opensource.com/article/19/4/gpg-subkeys-ssh
Update: Working Configuration (thanks again to @SystematicFrank)
# ~/.zshrc
export GPG_TTY=$(tty)
# ~/.gnupg/gpg-agent.conf
pinentry-program /usr/bin/pinentry-curses
default-cache-ttl 600
max-cache-ttl 7200
enable-ssh-support
# ~/.gnupg/gpg.conf
use-agent
# ~/.gnupg/sshcontrol
MYFINGERPRINTS
# ~/.ssh/config
Host localhost
ForwardAgent yes
AddKeysToAgent ask
Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"
|
The problem is that you are calling gpg-connect-agent updatestartuptty every time you open a terminal, so pinentry points itself to the latest shell.
What you actually want is not the latest shell terminal, but the one you are connecting from (when calling ssh)
For that the easiest way is telling .ssh/config to execute the update command from the tty you are connecting. This is the magic line you are missing:
Match host * exec "gpg-connect-agent UPDATESTARTUPTTY /bye"
| What is the proper configuration for gpg, ssh, and gpg-agent to use GPG auth subkeys for SSH with pinentry in a multi-session tmux environment? |
1,424,264,793,000 |
Notice: the very same vulnerability has been discussed in this question, but the different setting of the problem (in my case I don't need to store the passphrase) allows for a different solution (i.e. using file descriptors instead of saving the passphrase in a file, see ilkkachu's answer).
Suppose I have a symmetrically encrypted file my_file (with gpg 1.x), in which I store some confidential data, and I want to edit it using the following script:
read -e -s -p "Enter passphrase: " my_passphrase
gpg --passphrase $my_passphrase --decrypt $my_file | stream_editing_command | gpg --yes --output $my_file --passphrase $my_passphrase --symmetric
unset my_passphrase
Where stream_editing_command substitutes/appends something to the stream.
My question: is this safe? Will the variable $my_passphrase and/or the decrypted output be visible/accessible in some way? If it isn't safe, how should I modify the script?
|
gpg --passphrase $my_passphrase
My question: is this safe? Will the variable $my_passphrase and/or the decrypted output be visible/accessible in some way?
No, that's not really considered safe. The passphrase will be visible in the output of ps, just like all other running processes' command lines. The data itself will not be visible, the pipe is not accessible to other users.
The man page for gpg has this to say about --passphrase:
--passphrase string
Use string as the passphrase. This can only be used if only one passphrase is supplied. Obviously, this is of very questionable security on a multi-user system. Don't use this option if you can avoid it.
Of course, if you have no other users on the system and trust none of your services have been compromised there should be no-one looking at the process list.
But in any case, you could instead use --passphrase-fd and have the shell redirect the passphrase to the program. Using here-strings:
#!/bin/bash
read -e -s -p "Enter passphrase: " my_passphrase
echo # 'read -s' doesn't print a newline, so do it here
gpg --passphrase-fd 3 3<<< "$my_passphrase" --decrypt "$my_file" |
stream_editing_command |
gpg --yes --output "$my_file" --passphrase-fd 3 3<<< "$my_passphrase" --symmetric
Note that that only works if the second gpg doesn't truncate the output file before getting the full input. Otherwise the first gpg might not get to read the file before it's truncated.
To avoid using the command line, you could also store the passphrase in a file, and then use --passphrase-file. But you'd then need to be careful about setting up the access permissions of the file, to remove it afterwards, and to choose a proper location for it so that the passphrase doesn't get actually stored on persistent storage.
| Security of bash script involving gpg symmetric encryption |
1,424,264,793,000 |
I'm trying to copy my gpg related files over from an old machine to a new one.
I've worked out how to copy the keys over: How to import secret gpg key (copied from one machine to another)? but this leaves me with gpg complaining that it doesn't trust the imported keys.
How do I transfer the trust db from one machine to another?
|
You can copy ~/.gnupg/trustdb.gpg from one machine to another.
You can also export the ownertrust values (which are the ones that matter) and import them on the new machine:
gpg --export-ownertrust > otrust.txt
rm ~/.gnupg/trustdb.gpg
gpg --import-ownertrust < otrust.txt
See the gpg manpage for details (although the version on the website doesn't say much more than I have).
| How to migrate GPG trust database from one machine to another? |
1,424,264,793,000 |
I have some public keys of multiple users in my keyring in GnuPG. One of these users has switched to a new public key. I still have the user's old key which has an assigned trust of ultimate. I just assigned the same trust to his new key.
He does not use the old key anymore. What should I do with the old key? Should I withdraw trust, or revoke it? What is the correct procedure in such a case?
|
First of all, ultimate trust shouldn't be used for other's keys, full trust is enough. If you issued ultimate trust to make the key itself valid, you missunderstood the web of trust concept. If you just wanted all his certifications to be valid for you (thus, extending your web of trust), full trust is enough, if you at the same time certified him.
Regarding your actual question: this depends a little bit on the situation.
You will not be able to revoke the other's key. Has the key's owner revoked it? If so, he should just send you the revocation certificate -- for example by uploading it to the key servers, where you can fetch it again. If the key is revoked, you do not have to care about trust any more anyway.
The key owner has lost control over the key, but cannot revoke it any more. For example, somebody stole the laptop with the only copy of the key, and the owner doesn't have a revocation certificate (very bad idea). Now it's at you to fix the situation, by withdrawing trust and setting it to "never". Also consider doing the same with his new key, as there seem to be major issues with the owner's key handling. This does not change validity if his key (if you signed it), it just makes sure certifications issued by it won't be used for validity calculation of others.
The key owner just doesn't want to use the key any more, but still owns it and wants to keep the reputation in the web of trust he build up (which you probably also want to make use of): Just import his new key, and don't care about the old one at all. Apart from changing trust from "ultimate" to "full".
If you want to make sure you're not accidentially encrypting to his old key, disable it by running gpg --edit-key [key-id], then using GnuPG's disable command.
| What to do when a user switches to a new key? |
1,424,264,793,000 |
I have a Yubikey 4 and I want to use my GPG keys stored on this to authenticate to SSH servers.I want to use GitHub for a start. I have already added my GPG authentication key to GitHub.
My problem is that when I ssh, my agent doesn't use this key. I've checked by trying to connect to my VPS with ssh -v but it skips my GPG key. My Yubikey is plugged in and gpg2 --card-status shows all the details. I am able to sign and decrypt fine as well as use the other features of the Yubikey.
The ssh ouput
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /home/wilhelm/.ssh/id_rsa
debug1: Trying private key: /home/wilhelm/.ssh/id_dsa
debug1: Trying private key: /home/wilhelm/.ssh/id_ecdsa
debug1: Trying private key: /home/wilhelm/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
I have disabled gnome password manager.
I've looked at Connecting SSH and Git to gpg-agent and followed the suggestion, but it doesn't seem to be working.
╰─ ssh-add -l
Could not open a connection to your authentication agent.
╰─ ps aux | grep gpg-agent
wilhelm 26079 0.0 0.0 20268 980 ? Ss 20:57 0:00 gpg-agent --daemon --enable-ssh-support --sh
wilhelm 31559 0.0 0.0 12724 2184 pts/1 S+ 22:49 0:00 grep --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn gpg-agent
|
ssh can't open connection to your gpg-agent if you will not give it the way to do so.
When you start your gpg-agent with --enable-ssh-support option, it prints out environmental variables that needs to be available in the shell where from you will be using your ssh. There are few possibilities how to get them:
Stop your gpg-agent and start it once more in like this in the shell where from you are using your ssh (this should be the easiest way to test it):
eval $(gpg-agent --daemon --enable-ssh-support --sh)
Find the location of authentication socket and set up the environment variable SSH_AUTH_SOCK by hand
Later on, when you will know that it works, you should set up the agent start according to the manual page for gpg-agent(1), so probably in ~/.xsession to let it start automatically.
| gpg-agent instead of ssh-agent |
1,424,264,793,000 |
Debian Jessie, XFCE 4.10, KeePass2, IceDove (with Enigmail)..
I'm using KeePass2 generated passwords for my gpg private key, to de/encrypt mails. Icedove is my client which uses the enigmail.
As soon as I want to de/encrypt a mail pinentry (pinentry-gtk2) pops up and I can't paste into the password field, nor can I move it - thus I'd like to have KeePass2 auto-type my long-ass password for me. Which does not work with the keyboard shortcut (working for anything else), but with a right-click in the KeePass2 entry for 'perform auto-type'.
this is slowly driving me nuts.. I've now read a ton of forum discussions - where none were really helpful and tried to alter my gpg-agent settings to use pinentry-curses. I even removed pinentry-gtk2 which rendered icedove completly incapable of de/encryption.
Any suggestions to make the auto-type feature or paste working in the pinentry window. Or an alternative pinentry?
|
In Keepass2, "Add Entry," and set "Title" to "GPG." Move from "Entry" tab to "Auto-Type" tab. Select "Override default sequence" and set to "{PASSWORD}".
Before you send email, open Keepass2 with Keepass2 password. Ask IceDove with Enigmail to "Send" and pinentry should appear (locking keyboard, preventing "Ctrl+V" (or any other keyboard shortcut you normally use to perform auto-type), preventing switch windows "Alt+Tab", etc.).
Use mouse to highlight "GPG" entry in Keepass2 and click "Perform Auto-Type" icon in Keepass2 (left of "Find" icon and underneath "Help" menu). As the keyboard "focus" was last on the pinentry text input box, Keepass2 will now start typing your long password for you.
Use mouse to click "OK" on pinentry. Done!
For more details on "Auto-Type" (http://keepass.info/help/base/autotype.html).
| Usage of pinentry with keepass2 for gpg mail encryption |
1,424,264,793,000 |
In gpg's man page, there are examples of key IDs :
234567C4
0F34E556E
01347A56A
0xAB123456
234AABBCC34567C4
0F323456784E56EAB
01AB3FED1347A5612
0x234AABBCC34567C4
and fingerprints :
1234343434343434C434343434343434
123434343434343C3434343434343734349A3434
0E12343434343434343434EAB3484343434343434
0xE12343434343434343434EAB3484343434343434
My intuition would have been that a leading 0 is for octal and a leading 0x for hexadecimal, but it does not seem like it is.
What are the different representations?
|
NOTE: Before I begin, all the representations here are hexidecimal only. There isn't any other representation.
Key IDs
The man page seems pretty clear on where these values are coming from. The key IDs are a portion of the SHA-1 fingerprint.
The key Id of an X.509 certificate are the low 64 bits of its SHA-1 fingerprint. The use of key Ids is just a shortcut, for all automated processing the fingerprint should be used.
All these values are hex, the notation allows for either a number to be prefixed with 0x, a 0, or to simply begin with a non-zero value.
NOTE: Using key IDs is inherently a bad idea since they're essentially taking a portion of the fingerprint to identify a given key. The problem arises in that it's somewhat trivial to generate collisions among key IDs. See this article for more on this issue, titled: Short key IDs are bad news (with OpenPGP and GNU Privacy Guard).
excerpt
Summary: It is important that we (the Debian community that relies on OpenPGP through GNU Privacy Guard) stop using short key IDs. There is no vulnerability in OpenPGP and GPG. However, using short key IDs (like 0x70096AD1) is fundementally insecure; it is easy to generate collisions for short key IDs. We should always use 64-bit (or longer) key IDs, like: 0x37E1C17570096AD1 or 0xEC4B033C70096AD1.
TL;DR: This now gives two results: gpg --recv-key 70096AD1
Fingerprints
Whereas the fingerprints:
This format is deduced from the length of the string and its content or the
0x prefix. Note, that only the 20 byte version fingerprint is available with
gpgsm (i.e. the SHA-1 hash of the certificate).
When using gpg an exclamation mark (!) may be appended to force using the
specified primary or secondary key and not to try and calculate which primary or
secondary key to use.
The best way to specify a key Id is by using the fingerprint. This avoids any
ambiguities in case that there are duplicated key IDs.
I'd suggest taking a look at the wikipedia page titled: Public key fingerprint. It details how fingerprints are generated. Here's summary:
excerpt
A public key (and optionally some additional data) is encoded into a sequence of bytes. To ensure that the same fingerprint can be recreated later, the encoding must be deterministic, and any additional data must be exchanged and stored alongside the public key. The additional data is typically information which anyone using the public key should be aware of. Examples of additional data include: which protocol versions the key should be used with (in the case of PGP fingerprints); and the name of the key holder (in the case of X.509 trust anchor fingerprints, where the additional data consists of an X.509 self-signed certificate).
The data produced in the previous step is hashed with a cryptographic hash function such as MD5 or SHA-1.
If desired, the hash function output can be truncated to provide a shorter, more convenient fingerprint.
This process produces a short fingerprint which can be used to authenticate a much larger public key. For example, whereas a typical RSA public key will be 1024 bits in length or longer, typical MD5 or SHA-1 fingerprints are only 128 or 160 bits in length.
When displayed for human inspection, fingerprints are usually encoded into hexadecimal strings. These strings are then formatted into groups of characters for readability. For example, a 128-bit MD5 fingerprint for SSH would be displayed as follows:
43:51:43:a1:b5:fc:8b:b7:0a:3a:a9:b1:0f:66:73:a8
References
Fingerprint (computing)
| GnuPG : representations of key IDs and fingerprints |
1,424,264,793,000 |
When you --gen-key in GPG, you can choose which actions of Sign, Certify, Encrypt, and Authenticate the key will be usable for.
Can these be later modified (i.e. obviously a new key can be created if the current one has C, and the old one revoked, but that's not the question) to remove or add actions?
|
Keys' allowed usages can be modified, but the gpg tool doesn't support it (even in version 2). To change a key's usage, you need to modify gpg. The basic idea is detailed in a thread on the gnupg-users mailing list: usage information is carried by the self-signature, so you need to change the usage parser to force the value you're interested in, then create a new self-signature on your key, for example by changing your key's expiry date.
| Change a key's allowed actions in GPG? |
1,424,264,793,000 |
I've just upgraded readline to a new major release:
$ grep readline.*7 /var/log/pacman.log
[2016-11-15 21:53] [ALPM] upgraded readline (6.3.008-4 -> 7.0-1)
Since this GNUPG is broken:
$ gpg
gpg: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory
That also means I can't upgrade any packages. How do I safely fix my installation?
What I've tried so far to downgrade readline:
The package is not in /var/cache/pacman/pkg
Building from the previous PKGBUILD failed because it doesn't bootstrap itself - it relies on awk which is also missing libreadline.so.6.
|
This has been reported to Arch here.
The workaround is to run
mkinitcpio -P
after the upgrade has completed, but before rebooting.
If you've rebooted before re-running mkinitcpio, then you'll need to boot off e.g. a USB key and run the mkinitcpio from the chroot. The easiest is to use arch-chroot as in the Arch install instructions.
I haven't had a chance to test this method in this particular case, however have done so in the past.
| gnupg on Arch Linux broken since readline upgrade - can't find libreadline.so.6 |
1,424,264,793,000 |
In order to compile a new kernel on my Debian jessie, I am trying to verify the GPG key , following the instruction on the official website.
I have download the the linux-3.18.35.tar.sign and linux-3.18.35.tar.xz version and unzip it using unzx.
To verify the .tar archive using the command :
gpg --verify linux-3.18.35.tar.sign
I get:
gpg: assuming signed data in `linux-3.18.35.tar'
gpg: Signature made Wed 08 Jun 2016 01:19:29 AM CET using RSA key ID 6092693E
gpg: Can't check signature: public key not found
To get the public key from the PGP keyserver :
#gpg --keyserver hkp://keys.gnupg.net --recv-keys 6092693E
gpg: requesting key 6092693E from hkp server keys.gnupg.net
?: keys.gnupg.net: Host not found
gpgkeys: HTTP fetch error 7: couldn't connect: Connection refused
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
I get a similar problem with the 4.4.13 version too.
I have tried the following answer,
# gpg --keyserver subkeys.pgp.net --recv-keys 6092693E && gpg --export --armor 6092693E | sudo apt-key add -
gpg: requesting key 6092693E from hkp server subkeys.pgp.net
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
And:
# gpg --keyserver subkeys.pgp.net:80 --recv-keys 6092693E
gpg: requesting key 6092693E from subkeys.pgp.net:80
gpgkeys: no keyserver host provided
gpg: keyserver internal error
gpg: keyserver receive failed: keyserver error
How to verify the kernel signature correctly?
|
You only need to have the public key in your keyring:
gpg --keyserver subkeys.pgp.net --recv-keys 0x38DBBDC86092693E
(use the long identifier!). If it times out, try again — there are multiple servers, and some of them seem to be having issues currently. apt-key etc. aren't involved in this at all.
Once you have the key in your keyring,
gpg --verify linux-3.18.35.tar.sign
should work.
You can also configure a key server pool instead (this is a good idea anyway):
install gnupg-curl (apt-get install gnupg-curl on Debian);
download the SKS CA
cd ~/.gnupg; wget https://sks-keyservers.net/sks-keyservers.netCA.pem
verify it;
add the following line to your ~/.gnupg/gpg.conf, or change it if it's already present:
keyserver hkps://hkps.pool.sks-keyservers.net
and set up the certificate by either adding
keyserver-options ca-cert-file=/home/.../.gnupg/sks-keyservers.netCA.pem
to ~/.gnupg/gpg.conf (for GnuPG 1) or
keyserver hkps://hkps.pool.sks-keyservers.net
hkp-cacert /home/.../.gnupg/sks-keyservers.netCA.pem
to ~/.gnupg/dirmngr.conf (for GnuPG 2), replacing the ... in the path with the appropriate value for your home directory in both cases.
Once you've done that,
gpg --recv-keys 0x38DBBDC86092693E
should retrieve the key reliably.
If all that fails, you can download and import the key manually:
curl 'http://pgp.surfnet.nl:11371/pks/lookup?op=get&search=0x38DBBDC86092693E' > gregkh.key
gpg --import gregkh.key
| Unable to verify the kernel signature "gpg: Can't check signature: public key not found" |
1,424,264,793,000 |
I would like to query gpg to list only the keys that I own on my local keyring. How is this done? I can see all keys by doing
gpg list-keys
-- that shows all the keys. I want just my keys.
|
Assuming you have private keys on your machine only for your keys, you could do with listing private keys with
gpg --list-secret-key
This will show you only keys that have a private counterparts.
Otherwise, you can list either all or single key.
| how can I get gpg to list only my keys? |
1,424,264,793,000 |
I recently got a Yubikey and loaded keys onto it following the directions here. gpg successfully reads and writes to the card, and I can see the key fingerprints from it it. However, when I try to use gpg --edit-card then fetch to get the key stubs, nothing happens. There is no error, but also my keys do not appear.
When I check journalctl -f, there is a message from dirmngr:
Apr 14 12:02:25 {snip} gpg-agent[1816]: card has S/N: D27{...snip...}0000
Apr 14 12:02:33 {snip} dirmngr[1823]: command 'KS_GET' failed: Server indicated a failure <Unspecified source>
man gpg sends me to the gnupg.org documentation, which gives instructions for transferring keys to the card (Section 5.2.2), but only says "You can sign, de- and encrypt files the usual way". My end goal is to use pass to securely store passwords, but when I try to use it in the usual way, I see gpg: decryption failed: No secret key.
What should I do differently?
I am using Arch Linux with gnupg from the main repository, version 2.2.15-1.
For reference, here is a complete listing of my gpg session:
$ gpg --list-secret-keys
$ gpg --list-keys
$ gpg --edit-card
Reader ...........: 1050:0407:X:0
Application ID ...: D27{...snip...}0000
Version ..........: 2.1
Manufacturer .....: Yubico
Serial number ....: 0{...snip...}6
Name of cardholder: [not set]
Language prefs ...: [not set]
Sex ..............: unspecified
URL of public key : [not set]
Login data .......: [not set]
Signature PIN ....: not forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 127 127 127
PIN retry counter : 3 3 3
Signature counter : 0
Signature key ....: 8DD5 {...snip...} C8B3
created ....: 2019-04-13 23:49:11
Encryption key....: B9B0 {...snip...} 9B22
created ....: 2019-04-13 23:49:11
Authentication key: 6447 {...snip...} 21C0
created ....: 2019-04-13 23:53:30
General key info..: [none]
gpg/card> fetch
gpg/card> quit
$ gpg --list-secret-keys
$ gpg --list-keys
|
GPG Smart Card Mini-How-To
Short Answer
It seems the secret keys are properly copied to the Yubikey smart card. However, the public key is missing from the local keyring. In order for gpg to work properly, the public key must be available locally.
There are several methods to import the public key. However, there is a handy field on the smart card for storing a URL where the public key can be found. So, if the public key is placed in a publicly accessible location on the Internet, the public key can be retrieved and added to the local keyring by using the fetch option in either the gpg/card menu or the --fetch-keys URL option on the gpg command line.
Once the local keyring knows about the public key, the private keys stored on the smart card should operate normally using the set user pin to unlock the keys.
Mini-How-To
This tutorial will run through the creation of a passphraseless PGP key set, loading the secret keys on a smart card, posting the public key on the Internet, and basic use of the card.
Please note that the key included on this post is a test and demonstration key only. It has no passphrase and can be imported locally via copy and paste if so desired. However, please do not use this test key for any purpose except testing.
GPG Version
gpg --version
gpg (GnuPG) 2.2.12
libgcrypt 1.8.4
Key generation
Let's generate a key to play with:
$ cat << EOF | gpg --gen-key --batch -
> Key-Type: rsa
> Key-Length: 2048
> Key-Usage: sign
> Subkey-Type: rsa
> Subkey-Length: 2048
> Name-Real: demo card
> Name-Comment: DeleteMe
> Name-Email: [email protected]
> %no-protection
> %commit
> EOF
Here's the secret key
gpg --armor --export-secret-key [email protected]
-----BEGIN PGP PRIVATE KEY BLOCK-----
lQEmBFy0xCUBCAC4WZl7y5QYe7k8g1/JV21hrvgE7A1LWFbCnX8CP35poGfUfJEz
/GB7s0j1D9nvQIse2QOfQQO+f9rJOfiB4Cc7vqXZghFS0lESgluK4M9ygQJwizvt
yJG0517zD3sKeqBO19EB4ElEPkcvQRrbKvPLXlL7mdjIGPpmIdSZh7u+28Qedv6a
2d7WHXXH7dfVDt5izRxn9ar9qyGO54AIHmHJ0O2RyPW8kaYsRESdHs2klbHtHN+n
mvV85+jQ7DABh3A8VlaMtXLRNt79osUSNPLiUh8ZltXcbb3flwCVrRxR2cQBN9P/
qoOFhkTe92RipUQENr5CEeK2t+Zk64JQfSLPABEBAAH/AGUAR05VAhDSdgABJAEC
AXYVAAAAGQAAtCtkZW1vIGNhcmQgKERlbGV0ZU1lKSA8ZGVtby5jYXJkQGRvbWFp
bi50bGQ+iQFOBBMBCgA4FiEE9Epupl6CF0Nug+LC8WY6apR5OYcFAly0xCUCGwMF
CwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8WY6apR5OYfZBwf+LGeEA0zJlzdC
WGuZ3lRJoeLRaLgUNy6ZatJMudggE5u2yO0omIlaQooLmsqtnNwi5y8W5BzrdYPe
yzkdyZqmfW8IgxlW8n7lngkkVJ44xUI2aMsDRMDH+09Q3bHXihgaDbgwLyXwJe8f
bHByeLD0penL/GscR0vlmp4ZcoxwB6elsJdamhDQgbg2BD/zeomAPwLymsvDZL+5
Q4KpX3iyD7jV0CzM9ApEbhwDJ7RaBaFryz0p0LuZOHKC4f2thPxZ6Q53Qi/k11Er
m+rG35qIG+IfKASCUHzhhz0pVKGzhg3n2YmzupVHFfN8ARA/L3kNDrIuvsQhVHqq
OPq4WPgBY50BJgRctMQlAQgAoA1nDFyGJp63D/WvYurZxovqEjL5fGBD8JOXMiUN
9m8V8NhSFwDHl/p52ZQp/OAA67uuj7UScrsGAVwotTXMyGMnuoEQDE9nRBRbc3zX
XEfXDmpnEv5NqqyBVe0mbkLwN3mbdV/JcQDZo+5TMqWWnboB+kBa3JPJbKydJYjH
2XTzUFGlLAL28ArXCmoBCO1IyCLDJzUUZWuuyTCeTVF5IB3aJ25G3y7I07bK9EyC
smaddDueHoDFv2hrs3vcTW5cVkbzeYil7i8H84Fxsn9InAKBrAdEtN2FEWBripS+
Y7dSGgKpOxFgf6tDB6EbW9UDWebWLrhUgY43WP/A8i15/wARAQAB/wBlAEdOVQIQ
0nYAASQBAgF2FQAAABkAAIkCbAQYAQoAIBYhBPRKbqZeghdDboPiwvFmOmqUeTmH
BQJctMQlAhsuAUAJEPFmOmqUeTmHwHQgBBkBCgAdFiEE63Vmygf/nE+U7ZJGtFWa
qgYkqc8FAly0xCUACgkQtFWaqgYkqc9RkAgAlrFqM69D1a8gm/xYyRGAy/cU3NGr
P8peoA0WpA0xnJCy+ZZdLD33fHrAC0CNjlpkXD2k8KLPCzTrrGwcbjIeR3Rnw5rJ
xkQyDkZmA6qrpFxDopf8oopP6s38bXErHdWhFPn9YLeWTNc8hVLOrHck2OvbXw2G
PQc4ULtmGv7FaSaijV7DuC6yZ20k+Kx40V4QyprYlClN++WdaWXban3BxwFMiuhp
Q/TadscHzHzbvEi8XTjYQlhLbvI4IIJTA7K8JbhrUZaniKnPC1gTqSLD320gwpnX
9ZrQPmexzxtkk97ZOWhUmrcK6ZQ767U6umN2tQLnkPmHSkIyfOu4nyfj33i+B/wP
3iwWNOM+CX0vB1FhixeJ4TjuhmLe3rZq264lnC2UuJbiGM/gwJegtR86xAwvcR/l
zuK/kxbAhQko8yNgB2qAjxQNO4DiSgsyWGKbCGcNC6vs9zSiLfe4f+AhfvUyXQ3+
yGmm+mhQgc097TkijMmZMJn/zg/WFVPJb45LRlA15Pg7n5769H1//7QLDZEnBfOx
PAUDGv+S8vZZRE+WE7X4VTnLDWZzCS03iUgHd4YMbcbmijLDwiqK31wqitJBNcDN
em3oWz1wfTioaISSWyxy03SK2Kjj+6zxA/mbZWr4L9pXBRwCVS6QQ3Bgie0kuZSP
NQSlYESEFuIGA3+WuBy2
=V4D1
-----END PGP PRIVATE KEY BLOCK-----
Key Listing
gpg --edit-key F1663A6A94793987
Secret key is available.
sec rsa2048/F1663A6A94793987
created: 2019-04-15 expires: never usage: SC
trust: ultimate validity: ultimate
ssb rsa2048/B4559AAA0624A9CF
created: 2019-04-15 expires: never usage: SEA
[ultimate] (1). demo card (DeleteMe) <[email protected]>
Placing the Public Key online somewhere
gpg -a --export F1663A6A94793987
https://pastebin.com/raw/y8gCBFmH
Add keys and URL to card
gpg --edit-card
gpg/card> url
URL to retrieve public key: https://pastebin.com/raw/y8gCBFmH
gpg --edit-key F1663A6A94793987
gpg> keytocard
Really move the primary key? (y/N) y
Please select where to store the key:
(1) Signature key
(3) Authentication key
Your selection? 1
gpg> key 1
sec rsa2048/F1663A6A94793987
created: 2019-04-15 expires: never usage: SC
trust: ultimate validity: ultimate
ssb* rsa2048/B4559AAA0624A9CF
created: 2019-04-15 expires: never usage: SEA
[ultimate] (1). demo card (DeleteMe) <[email protected]>
gpg> keytocard
Please select where to store the key:
(1) Signature key
(2) Encryption key
(3) Authentication key
Your selection? 2
gpg> save
Delete the keys from the keyring
gpg --delete-secret-keys F1663A6A94793987
sec rsa2048/F1663A6A94793987 2019-04-15 demo card (DeleteMe) <[email protected]>
Delete this key from the keyring? (y/N) y
This is a secret key! - really delete? (y/N) y
gpg --delete-keys F1663A6A94793987
pub rsa2048/F1663A6A94793987 2019-04-15 demo card (DeleteMe) <[email protected]>
Delete this key from the keyring? (y/N) y
Similar state as the OP
gpg --edit-card
Reader ...........: 04E6:xx:0
Application ID ...: D27600xxxx0190000
Version ..........: 2.1
Manufacturer .....: unknown
Serial number ....: 00000019
Name of cardholder: [not set]
Language prefs ...: [not set]
Sex ..............: unspecified
URL of public key : https://pastebin.com/raw/y8gCBFmH
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 127 127 127
PIN retry counter : 3 3 3
Signature counter : 0
Signature key ....: F44A 6EA6 5E82 1743 6E83 E2C2 F166 3A6A 9479 3987
created ....: 2019-04-15 17:49:25
Encryption key....: EB75 66CA 07FF 9C4F 94ED 9246 B455 9AAA 0624 A9CF
created ....: 2019-04-15 17:49:25
Authentication key: [none]
General key info..: [none]
Use Keys on Card
Retrieve Public Key
gpg/card> fetch
gpg: requesting key from 'https://pastebin.com/raw/y8gCBFmH'
gpg: key F1663A6A94793987: public key "demo card (DeleteMe) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
gpg/card> list
Reader ...........: 04E6:xx:0
Application ID ...: D27600xxxx0190000
Version ..........: 2.1
Manufacturer .....: unknown
Serial number ....: 00000019
Name of cardholder: [not set]
Language prefs ...: [not set]
Sex ..............: unspecified
URL of public key : https://pastebin.com/raw/y8gCBFmH
Login data .......: [not set]
Signature PIN ....: forced
Key attributes ...: rsa2048 rsa2048 rsa2048
Max. PIN lengths .: 127 127 127
PIN retry counter : 3 3 3
Signature counter : 0
Signature key ....: F44A 6EA6 5E82 1743 6E83 E2C2 F166 3A6A 9479 3987
created ....: 2019-04-15 17:49:25
Encryption key....: EB75 66CA 07FF 9C4F 94ED 9246 B455 9AAA 0624 A9CF
created ....: 2019-04-15 17:49:25
Authentication key: [none]
General key info..:
pub rsa2048/F1663A6A94793987 2019-04-15 demo card (DeleteMe) <[email protected]>
sec> rsa2048/F1663A6A94793987 created: 2019-04-15 expires: never
card-no: 7615 00000019
ssb> rsa2048/B4559AAA0624A9CF created: 2019-04-15 expires: never
card-no: 7615 00000019
Almost Ready for Use
gpg --edit-key F1663A6A94793987
Secret key is available.
sec rsa2048/F1663A6A94793987
created: 2019-04-15 expires: never usage: SC
card-no: 7615 00000019
trust: unknown validity: unknown
ssb rsa2048/B4559AAA0624A9CF
created: 2019-04-15 expires: never usage: SEA
card-no: 7615 00000019
[ unknown] (1). demo card (DeleteMe) <[email protected]>
What happened to the Trust of the key?
GPG stores trust separately from the key material. This trust setting is what enables the Web of Trust. So, when a given key is imported into a local keyring, that key is not assigned a trust level. However, this is easy to change interactively.
gpg --edit-key F1663A6A94793987
gpg> trust
sec rsa2048/F1663A6A94793987
created: 2019-04-15 expires: never usage: SC
card-no: 7615 00000019
trust: unknown validity: unknown
ssb rsa2048/B4559AAA0624A9CF
created: 2019-04-15 expires: never usage: SEA
card-no: 7615 00000019
[ unknown] (1). demo card (DeleteMe) <[email protected]>
Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
Now the key is fully ready
gpg --list-key F1663A6A94793987
pub rsa2048 2019-04-15 [SC]
F44A6EA65E8217436E83E2C2F1663A6A94793987
uid [ultimate] demo card (DeleteMe) <[email protected]>
sub rsa2048 2019-04-15 [SEA]
Let's try it out
gpg -ear F1663A6A94793987
Hello there!
-----BEGIN PGP MESSAGE-----
hQEMA7RVmqoGJKnPAQf/V5CAzRCQ8gmAczy5i66e6w93CRYDiJ/1fNfL6ey2lYx2
cu/I3I12455Z8YjnLk3q66LW0gkhaxVX1uhtBXgjglz2RX6wMAYSDMvVs4cfIgq4
VLbW8T2y8ThdXvpGfwtgBgfFV5M2QS46RipXeF5rOCOnGeI8IUuzAC2147/qjcHG
+/wWDaker7NfY8GSgJ8OXd6kTmpZ//1zOTYvJVsE80viByv2Hx42Zu0r6e3KqgeR
qQlNA/zevYYjm4S0tkmxYoDb42gTPClNiHkJa3IXYlwYPzLCSszBsaTfHZdHl7yx
8PshF7fmE/NOO0dhHq2cV+fqPq8uT/VlNcPm3TYNxtJIAfnuTuHcorOuQNh0koML
8WWTIlLbj9OfBsZVsy5cp5ggpSLrCdPYd1g7RzEwRxu8QrWNO+pj2VRTtEZMafXq
XsKGJIgxsbJQ
=nwdE
-----END PGP MESSAGE-----
gpg -d
Please unlock the card
Number: 7615 00000019
Holder:
PIN:
gpg: encrypted with 2048-bit RSA key, ID B4559AAA0624A9CF, created 2019-04-15
"demo card (DeleteMe) <[email protected]>"
Hello there!
Use with pass
pass init F1663A6A94793987
mkdir: created directory '/home/user/.password-store/'
Password store initialized for F1663A6A94793987
pass insert password1
Enter password for password1: <qwerty>
Retype password for password1: <qwerty>
pass show password1
Please unlock the card
Number: 7615 00000019
Holder:
PIN:
qwerty
Usage notes
If a given password store is initialized with a key that is not located on a card. The pass script will not be able to locate the secret key if it is then moved to a smart card.
| Why does gpg fail to fetch key stubs from my smart card? |
1,424,264,793,000 |
I have a .tar.xz file which I would like to detach-sign using my gpg private key.
The problem is, I have multiple of private keys imported to my keyring and need to choose, which one to use.
Progress
This I am trying to execute:
gpg --output somefile.tar.xz.sig --detach-sig somefile.tar.xz --local-user [fingerprint]
but I get an error:
gpg: Note: '--local-user' is not considered an option
gpg: can't open '--local-user': No such file or directory
gpg: signing failed: No such file or directory
What am I doing wrong here and how do I fix it?
|
Solution
I have been to remedy the situation using the following working example:
gpg --local-user [fingerprint] --sign --armor --output somefile.tar.xz.asc --detach-sig somefile.tar.xz
Parsing
gpg: the program doing the signing; in my case version 2.2.4
--local-user: takes an ID as an argument or a fingerprint in my case.
--sign: action for gpg to do.
--armor: outputs human-readable characters instead of binary.
--output: takes a non-existing file name as an argument, this is to be the result of gpg's work. In case it exists, it will ask you if you wish to overwrite.
--detach-sig: instructs gpg not to sign the file directly and create a separate signature file.
Non-working examples
If you put the --local-user and its argument on the end, instead of the beginning, you will get the error as is in my question:
gpg --sign --armor --output somefile.tar.xz.asc --detach-sig somefile.tar.xz --local-user [fingerprint]
So, the --local-user and its argument shall come first (if possible).
If you reverse the --output and --detach-sig, you will get an error similar to what is my question:
gpg --local-user [fingerprint] --sign --armor --detach-sig somefile.tar.xz --output somefile.tar.xz.asc
Conclusion
The order of given arguments matters. That is why it failed.
| How to detach-sign a file with a specific private key? || Why this fails? |
1,424,264,793,000 |
I want to import my old gpg2 secret keyring from a backup. I only have my old .gnupg directory.
But all files in this folder are unrecognized by gpg2, which says "No valid OpenPGP data found" when I try to --import them.
How can I import my old secret keys ?
|
Solved it by replacing my new .gnupg directory by the old one, exporting the keys in an importable format, then restoring my new .gnupg and importing the keys :
mv ~/.gnupg ~/.new_gnupg
cp -r old_backup/.gnupg ~
gpg2 --export-secret-keys > sec.gpg
rm -r ~/.gnupg
mv ~/.new_gnupg ~/.gnupg
gpg2 --import sec.gpg
| gpg2 won't import .key files : No valid OpenPGP data found |
1,424,264,793,000 |
I am using Arch Linux and trying to build a package from the AUR. In order to build this package I need to download source files from a repository. The Arch PKGBUILD lists a key as a validpgpkey. While I can download this key individually, it is also possible to configure GPG to auto retrieve the key with
keyserver-options auto-key-retrieve
There are obviously security implications in regards to the package building process. My understanding is that the auto-key-retrieve option is global and other programs may now start to automatically download keys. What type of security implications does that have?
|
The package build process itself is safe, even with automatic key retrieval: since validpgpkeys must list full fingerprints, the key that’s automatically retrieved is sure to be the correct one. The main use-case that’s affected by automatic key retrieval is detecting unwanted changes to the validpgpkeys declaration (but such changes should be manually verified anyway, not just when gpg complains that it doesn’t have the necessary key in its keyring).
The auto-key-retrieve option is indeed global, so enabling it means that any interaction with gpg involving a key that isn’t in your keyring will download that key from your default keyserver. The practical difference this makes depends on two factors: the verifications you make when downloading a key manually, and whether or not your key and the key you’re downloading are connected. Obviously, if you always verify keys out of band before adding them to your keyring, you don’t want to enable automatic key retrieval. If the keys you use are connected, and you use the trust information, that’s valid regardless of where the key comes from, so automatic key retrieval is safe then. In between those two extremes, it seems to me that if you use full fingerprints, automatic key retrieval is safe too; and if you don’t, the risks associated with keys are the same regardless of their origin (e.g. accepting something signed by an evil key as signed by the real key owner, or worse, encrypting something to an evil key thinking that you’re sending it to someone else).
Really the main caveat with auto-key-retrieve is that highlighted in the manual:
Note that this option makes a “web bug” like behavior possible. Keyserver or Web Key Directory operators can see which keys you request, so by sending you a message signed by a brand new key (which you naturally will not have on your local keyring), the operator can tell both your IP address and the time when you verified the signature.
| Safety of using auto-key-retrieve with GPG |
1,424,264,793,000 |
Is it possible to set up SSH (via pam for instance) to check the public key of the connecting client against a CA server?
I've tried with gnupg (via gpg-agent --daemon --enable-ssh-support) and also tried working with OpenCA which proved to be a challenge just to install.
Also, the documentation is horrific when it comes to both of these.
What I'd like to accomplish is something along the lines of:
[Client] --SSH--> "Server" <---> [CA Server]
The entire platform is *nix based and I'm open to suggestions right about now cause I've been stuck on this for a while now.
GnuPG
I've set it up in as simply as possible following these guides:
http://www.bootc.net/archives/2013/06/09/my-perfect-gnupg-ssh-agent-setup/
https://wiki.archlinux.org/index.php/GnuPG
My initial thought was to set up my own "key-server" which gpg can send and check for keys, but there's no information about this what so ever (or at least none that I could find).
And from what I understand I should be able to do ssh-add -l to list all my keys, but this gives me: The agent has no identities. which is not so odd because I've never specified where to fetch them but "it should just work"(...?).
The gpg.conf looks like:
... lots of default ...
personal-digest-preferences SHA512
cert-digest-algo SHA512
default-preference-list SHA512 SHA384 SHA256 SHA224 AES256 AES192 AES CAST5 ZLIB BZIP2 ZIP Uncompressed
homedir /etc/gnupg
use-agent
and my gpg-agent.conf:
pinentry-program /usr/bin/pinentry-curses
default-cache-ttl 10800
default-cache-ttl-ssh 10800
write-env-file /etc/gnupg/.gpg-agent-info
enable-ssh-support
And just to verify that i actually have a key and gpg is responding:
~]# gpg --list-keys
/etc/gnupg/pubring.gpg
----------------------
pub 4096R/#######2 2013-12-10 [expired: 2014-12-10]
uid Anton (...) <mail>
sub 4096R/#######5 2013-12-10 [expires: 2014-12-10]
OpenCA
When finally everything was in place and started, I get to a website that says my "symmetric keylength is too short" and I can't get past that.
|
I know this is a very old question. However, there are two answers to your question.
Getting GPG working with SSH.
You've done the first step, enabling-ssh-support in your gpg-agent.conf
But, you haven't supplied any PGP keys to use. In order to use PGP keys with ssh, you've got to export the public key in ssh format and add that to your remote host's ~/.ssh/authorized_keys file. Then add the keygrip of the private key to the file ~/.gnupg/sshcontrol.
To export a PGP public key as ssh:
$gpg -a --export-ssh-key [keyid]
To view a PGP keygrip:
$gpg --with-keygrip --list-secret-keys [keyid]
I usually create a suitable subkey for use with SSH. If you are using GPG 2.2.1 then you can even use ED25519.
$gpg --expert --edit-key [keyid]
gpg> addkey
Option 11 for ECC
Option A to add authentication
Option 1 for Curve 25519
Expire never
Create yes
gpg> save
Then export just the authentication subkey:
$gpg -a --export-ssh-key [auth subkeyid]!
The exclamation point selects just the indicated subkey.
You will also need to make sure the environment variables are set in your ~/.bashrc ... If you are running an Xwindow client, this is usually done for you via /etc//X11/Xsession.d/90gpg-agent with the following bash script:
agent_sock=$(gpgconf --list-dirs agent-socket)
export GPG_AGENT_INFO=${agent_sock}:0:1
if [ -n "$(gpgconf --list-options gpg-agent | \
awk -F: '/^enable-ssh-support:/{ print $10 }')" ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
fi
Once you've ensured the environment variables are set, any keygrips added to the ~/.gnupg/sshcontrol file will appear as authentication keys in the ssh-agent when you list the available identities:
$ssh-add -l
Note, you can change the shown hash via the -E option to show MD5 or SHA256.
Configuring SSH to use certificates
This is a rather complex question. Red Hat has a detailed walkthrough here:
Redhat SSH CA Tutorial
End
It's unclear if it's possible to use PGP keys as the SSH CA keys. I haven't tried that myself. However, I do use PGP keys on the client side. I find that it makes life very easy and is less cumbersome to manage SSH identities than using ssh-genkey generated keys.
| SSH + Certificate Authority server? |
1,424,264,793,000 |
I want to encrypt a file with a private key and decrypt it with a public key. A public key will be embedded in my app. So I want to have a guarantee that the file was created by me. How can I use gpg or openssl to implement it.
|
It makes no sense to encrypt a file with a private key.
Using a private key to attach a tag to a file that guarantees that the file was provided by the holder of the private key is called signing, and the tag is called a signature.
There is one popular cryptosystem (textbook RSA) where a simplified (insecure) algorithm uses has public and private keys of the same type, and decryption is identical to signature and encryption is identical to verification. This is not the case in general: even RSA uses different mechanisms for decryption and signature (resp. encryption and verification) with proper, secure padding modes; and many other algorithms have private and public keys that aren't even the same kind of mathematical objects.
So you want to sign the file. The de facto standard tool for this is GnuPG.
To sign a file with your secret key:
gpg -s /path/to/file
Use the --local-user option to select a secret key if you have several (e.g. your app key vs your personal key).
Transfer file.gpg to the place where you want to use the file. Transfer the public key as well (presumably inside the application bundle). To extract the original text and verify the signature, run
gpg file.gpg
If it's more convenient, you can transfer file itself, and produce a separate signature file which is called a detached signature. To produce the detached signature:
gpg -b /path/to/file
To verify:
gpg file.gpg file
You can additionally encrypt the file with the -e option. Of course this means that you need a separate key pair, where the recipient (specified with the -r option) has the private key and the producer has the public key.
| How to encrypt a file with private key |
1,481,718,407,000 |
I want to create a script that would automatically encrypt and push to GitHub into public repo some sensible files I don't want to expose (but do want to keep together with the whole project).
As a solution I decided to encrypt them with GPG. The issue is that I can't find any clues on how to encrypt a particular file with a passphrase passed as a CLI argument to a gpg -c command.
Does anybody know how to do this?
|
Use one of the --passphrase-... options, in batch mode:
--passphrase-fd reads the passphrase from the given file descriptor
echo mysuperpassphrase | gpg --batch -c --passphrase-fd 0 file
--passphrase-file reads the passphrase from the given file
echo mysuperpassphrase > passphrase
gpg --batch -c --passphrase-file passphrase file
--passphrase uses the given string
gpg --batch -c --passphrase mysuperpassphrase file
These will all encrypt file (into file.gpg) using mysuperpassphrase.
With GPG 2.1 or later, you also need to set the PIN entry mode to “loopback”:
gpg --batch -c --pinentry-mode loopback --passphrase-file passphrase file
etc.
Decryption can be performed in a similar fashion, using -d instead of -c, and redirecting the output:
gpg --batch -d --passphrase-file passphrase file.gpg > file
etc.
| Encrypt with GPG using a key passed as CLI argument |
1,481,718,407,000 |
I'm trying to change the passphrase of my GPG's secret key.
I actually changed it using seahorse (Also tried gpg --edit-keys and passwd, but when I tried to export my private key it asks me for two passphrase now (Both new and old one) and uses the old one for sub secret key.
Now I have to remember two complicated password!
What is the correct way to change the passphrase of GPG's secret key?
|
For GPG 2.1 and later, the private keys are stored in ~/.gnupg/private-keys-v1.d Each key, including subkeys, are stored as separate files using the keygrip of the key as the filename:
<keygrip>.key
When using gpg --edit-key to change the passphrase, all subkeys are modified in the private key directory.
However, it seems that seahorse is only modifying the main key's private key file.
So, it looks like this is a bug in seahorse. It may be a regression from earlier gpg versions which stored the private keys in a keyring structure just like the public keys. This behavior was changed in versions 2.1 and later.
Simple test results with test key, showing that seahorse only modifies the main key's private keyfile.
Test Key with three subkeys
pub ed25519 2018-12-24 [SC]
988D29CB7CA9D62252B22DEFB42E56952F9FB61C
Keygrip = 8226D19110BAC4FB4D60BC25869E5F23C1BB667F
uid [ultimate] delete me (Delete Me) <[email protected]>
sub cv25519 2018-12-24 [E]
Keygrip = 04B4D2C5CC29926F48DA2C4FD24F03B9595AE51C
sub ed25519 2019-03-25 [SA]
Keygrip = 269995721854253C5F8B48CB40DD24948D580F8C
sub ed25519 2019-03-25 [SA]
Keygrip = 604E0E8F9D9C2B19A823E22A90F08EC2DDCA80BB
Passphrase changed with seahorse
-rw------- 1 user user 333 Mar 25 09:27 8226D19110BAC4FB4D60BC25869E5F23C1BB667F.key
-rw------- 1 user user 333 Mar 25 09:08 604E0E8F9D9C2B19A823E22A90F08EC2DDCA80BB.key
-rw------- 1 user user 333 Mar 25 09:08 269995721854253C5F8B48CB40DD24948D580F8C.key
-rw------- 1 user user 341 Mar 25 09:08 04B4D2C5CC29926F48DA2C4FD24F03B9595AE51C.key
Passphrase changed with gpg --edit-key
-rw------- 1 user user 333 Mar 25 09:37 604E0E8F9D9C2B19A823E22A90F08EC2DDCA80BB.key
-rw------- 1 user user 333 Mar 25 09:37 269995721854253C5F8B48CB40DD24948D580F8C.key
-rw------- 1 user user 341 Mar 25 09:37 04B4D2C5CC29926F48DA2C4FD24F03B9595AE51C.key
-rw------- 1 user user 333 Mar 25 09:37 8226D19110BAC4FB4D60BC25869E5F23C1BB667F.key
Seahorse source code check
After reviewing some of the seahorse source code, it seems likely that the behavior lines up with the older secret keyring gpg methods.
According to gpgme documentation, the passphrase should be changed using the gpgme gpgme_op_passwd function call. However, this function call does not appear in the seahorse source code.
| How to correctly change the passphrase of GPG's secret key? |
1,481,718,407,000 |
I've been asked to distribute electronic certificates (they were originally paper), in a PDF format, but I'd like to sign them with gpg or something similar so users can upload them to my site to check that they've not been handed a fake copy.
So, I'd like to sign a PDF file (transparently, the user doesn't need to know about anything) and check if its valid.
|
You can do it with a separate signature file.
Sign the Document:
% gpg --output doc.pdf.sig --detach-sig doc.pdf
Distribute doc.pdf and doc.pdf.sig
Verify the Document:
% gpg --verify doc.pdf.sig doc.pdf
| Sign a PDF file to verify integrity and validity |
1,481,718,407,000 |
I have a lot of files encrypted with gpg. All files have the same password. Is it possible to use xargs to decrypt files?
ls | xargs -n 1 gpg asks for the password for every file.
|
Run gpg-agent or a similar program. Set up gpg to look for a running agent, as explained in the documentation. Enter the passphrase in the agent once and for all (for this session).
Note that ls | xargs -n 1 gpg only works if your file names do not contain any special characters. Generally speaking, don't parse the output of ls, and xargs is pointless when you want to run the program once per file. Do this instead:
for x in *.gpg; do gpg "$x"; done
| Decrypt files encrypted with gpg using xargs |
1,481,718,407,000 |
when using gpg with gpg-agent, following sockets are created in my ~/.gnupg directory:
S.gpg-agent
S.gpg-agent.browser
S.gpg-agent.extra
S.gpg-agent.ssh
I assume, S.gpg-agent is the standard gpg-agent socket. But what are the others for?
I am not using gpg with ssh, or gpg with browser.
Where is it configured, that these are created automatically?
Can I disable them ?
I only need the standard S.gpg-agent
I am using gnupg 2.2.12 on Debian Buster.
|
The gpg-agent can have multiple personalities and deliver different services.
For example, you can stop having ssh-agent running on your box, and use gpg-agent as a drop in replacement... as long as you use the proper socket, S.gpg-agent.ssh because it has to implement the proper protocol ssh is expecting to discuss. Why could be that useful? For example, until very recently, ssh was not able to use keys stored in FIDO2/U2F (like Yubikeys), this was only added in 8.2 released not long ago, which then makes things dead simple as explained in https://blog.snapdragon.cc/2020/02/23/direct-fido2-u2f-support-in-openssh-8-2-on-macos/
Before that, gpg-agent would be used, because gpg has support for the U2F thing as handled like a smartcard. This is one of the canonical documentation on how to do that: https://florin.myip.org/blog/easy-multifactor-authentication-ssh-using-yubikey-neo-tokens
Now back to gpg-agent, its full manual is at https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html#Invoking-GPG_002dAGENT
You can find all options at https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html#Agent-Options which can be put in a configuration file, typically ~/.gnupg/gpg-agent.conf
We can learn for example:
about the .extra one, we can learn both how to disable it and what it is used for:
--extra-socket name
The extra socket is created by default, you may use this option to change the name of the socket. To disable the creation of the socket use “none” or “/dev/null” for name.
Also listen on native gpg-agent connections on the given socket. The intended use for this extra socket is to setup a Unix domain socket forwarding from a remote machine to this socket on the local machine. A gpg running on the remote machine may then connect to the local gpg-agent and use its private keys. This enables decrypting or signing data on a remote machine without exposing the private keys to the remote machine.
For ssh support, the .ssh one:
--enable-ssh-support
--enable-putty-support
The OpenSSH Agent protocol is always enabled, but gpg-agent will only set the SSH_AUTH_SOCK variable if this flag is given.
In this mode of operation, the agent does not only implement the gpg-agent protocol, but also the agent protocol used by OpenSSH (through a separate socket). Consequently, it should be possible to use the gpg-agent as a drop-in replacement for the well known ssh-agent.
For the browser socket and more information you can use https://wiki.archlinux.org/index.php/GnuPG#gpg-agent that says:
gpg-agent is mostly used as daemon to request and cache the password for the keychain. This is useful if GnuPG is used from an external program like a mail client. gnupg comes with systemd user sockets which are enabled by default. These sockets are gpg-agent.socket, gpg-agent-extra.socket, gpg-agent-browser.socket, gpg-agent-ssh.socket and dirmngr.socket.
The main gpg-agent.socket is used by gpg to connect to the gpg-agent daemon.
The intended use for the gpg-agent-extra.socket on a local system is to set up a Unix domain socket forwarding from a remote system. This enables to use gpg on the remote system without exposing the private keys to the remote system. See gpg-agent(1) for details.
The gpg-agent-browser.socket allows web browsers to access the gpg-agent daemon.
The gpg-agent-ssh.socket can be used by SSH to cache SSH keys added by the ssh-add program. See #SSH agent for the necessary configuration.
The dirmngr.socket starts a GnuPG daemon handling connections to keyservers.
So there is no harm in having them even if you don't use them.
If you really want to make sure they are not there, you can try to put the following in a gpg-agent configuration file:
extra-socket /dev/null
browser-socket /dev/null
I did not test that, the documentation does not speak about browser-socket but this older question does: https://askubuntu.com/questions/777900/how-to-configure-gnupgs-s-gpg-agent-socket-location
| why does gpg-agent create several sockets |
1,481,718,407,000 |
I am trying to setup automatic signing of git commits with gpg. I have a private/public key pair, that I use to authenticate to the server and be able to push commits. I would like to use the same key for signing commits (because someone could authenticate as themselves, but push a commit with my name on it).
Is that possible? gpg --list-keys returns nothing!
|
Yes, you can auto-sign commits by setting the commit.gpgsign option.
However, you need a PGP-type key, not an SSH key. What you can do is use gpg-agent as an ssh agent.
| Use my ssh key to sign git commits |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.