date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,481,718,407,000 |
Trying to run this:
gpg -c --passphrase-file secret somefiletoencrypt
But it still asks for a password.
How do we make gpg use the password in the secret to do symmetric encryption?
|
From the gpg manual (man gpg2 on my system), in the section talking about the --passphrase-file option:
Note that since Version 2.0 this passphrase is only used if the
option --batch has also been given. Since Version 2.1 the
--pinentry-mode also needs to be set to loopback.
Testing for myself with GnuPG 2.2.12, adding --batch to your command makes it work as expected.
| gpg asks for password when supplying it in a file? |
1,481,718,407,000 |
What are the standard ownership settings for files in the .gnupg folder?
After doing sudo chown u:u * mine now looks like this:
drwx------ 2 u u 4,0K jan 18 22:53 crls.d
drwx------ 2 u u 4,0K jan 18 22:33 openpgp-revocs.d
drwx------ 2 u u 4,0K jan 18 22:33 private-keys-v1.d
-rw------- 1 u u 0 sep 28 02:12 pubring.gpg
-rw-rw-r-- 1 u u 2,4K jan 18 22:33 pubring.kbx
-rw------- 1 u u 32 jan 18 22:28 pubring.kbx~
-rw------- 1 u u 600 jan 19 22:15 random_seed
-rw------- 1 u u 0 sep 28 02:13 secring.gpg
srwxrwxr-x 1 u u 0 jan 20 10:20 S.gpg-agent
-rw------- 1 u u 1,3K jan 18 23:47 trustdb.gpg
However, before that, originally at least pubring.gpg,secring.gpg and random_seed were owned by root.
|
The .gnupg directory and its contents should be owned by the user whose keys are stored therein and who will be using them. There is in principle no problem with a root-owned .gnupg directory in your home directory, if root is the only user that you use GnuPG as (in that case one could argue that the directory should live in /root or that you should do things differently).
I can see nothing wrong with the file permissions in the file listing that you have posted. The .gnupg folder itself should additionally be inaccessible by anyone other than the owner and user of the keys.
The reason why the files may initially have been owned by root could be because GnuPG was initially run as root or by a process executing as root (maybe some package manager software or similar).
GnuPG does permission checks and will warn you if any of the files have unsafe permissions. These warnings may be turned off (don't do that):
--no-permission-warning
Suppress the warning about unsafe file and home directory
(--homedir) permissions. Note that the permission checks that
GnuPG performs are not intended to be authoritative, but rather
they simply warn about certain common permission problems. Do
not assume that the lack of a warning means that your system is
secure.
Note that the warning for unsafe --homedir permissions cannot be
suppressed in the gpg.conf file, as this would allow an attacker
to place an unsafe gpg.conf file in place, and use this file to
suppress warnings about itself. The --homedir permissions
warning may only be suppressed on the command line.
The --homedir directory referred to above is the .gnupg directory, usually at $HOME/.gnupg unless changed by using --homedir or setting GNUPGHOME.
Additionally, the file storing the secret keys will be changed to read/write only by default by GnuPG, unless this behaviour is turned off (don't do that either):
--preserve-permissions
Don't change the permissions of a secret keyring back to user
read/write only. Use this option only if you really know what
you are doing.
This applies to GnuPG 2.2.3, and the excerpts above are from the gpg2 manual on an OpenBSD system.
| What are the standard ownership settings for files in the `.gnupg` folder? |
1,481,718,407,000 |
I am migrating from ssh-agent to gpg-agent now and I also have a bunch of ssh keys, which are loaded at startup. The keys do not contain passphrases, but after calling ssh-add <filename>, gpg-agent asks for a passphrase. Just pressing Enter works fine, but could it not ask for passphrases at all? At least for the keys not having one?
|
Edit: I'm leaving this here for Google, but having bumped into this myself I no longer think this is the real problem.
gpg-agent likes to copy your keys and put its own pass-phrase protection on them when you ssh-add them the first time. From https://www.gnupg.org/documentation/manuals/gnupg/Agent-Options.html
SSH Keys, which are to be used through the agent, need to be added to the gpg-agent initially through the ssh-add utility. When a key is added, ssh-add will ask for the password of the provided key file and send the unprotected key material to the agent; this causes the gpg-agent to ask for a passphrase, which is to be used for encrypting the newly received key and storing it in a gpg-agent specific directory.
So it could be that that's what's happening, unless it keeps happening for the same keys. If they had passphrases originally I think you would get asked twice, once to unlock it and once to re-encrypt it.
| gpg-agent asks for a passphrase, but ssh private key doesn’t have one |
1,481,718,407,000 |
I'm installing cmake from the cmake.org website and they provide two files that I believe are intended to verify the source code download cmake-3.11.0-rc3.tar.gz
On the same page, they have links to download a cmake-3.11.0-rc3-SHA-256.txt file and a cmake-3.11.0-rc3-SHA-256.txt.asc file
What I don't understand is:
How does an asc file from the same source (cmake.org) ensure the source code's integrity? If the source code offered by the site was compromised, couldn't the attacker also compromise the asc file?
Don't I need a public key to truly verify the source code download? And I thought the asc file was supposed to be the public key. However, when I try to import the asc file with
gpg --import cmake-3.11.0-rc3-SHA-256.txt.asc
I get an error that says "no valid OpenPGP data found"
|
Have a look inside the .asc file, you will see it starts with:
-----BEGIN PGP SIGNATURE-----
So this is a PGP Signature. It means it signs some content with some specific PGP key.
1) The content
Based on the name, the content is the file .txt, it is the list of files corresponding to the software to download and each file has its corresponding hash.
2) The signature
If you launch gpg on both files, here is the result:
$ gpg --verify cmake-3.11.0-rc3-SHA-256.txt.asc cmake-3.11.0-rc3-SHA-256.txt
gpg: Signature made Fri Mar 9 10:29:10 2018 EST
gpg: using RSA key 2D2CEF1034921684
gpg: Can't check signature: No public key
So how does it all work? You are supposed to have the key 2D2CEF1034921684 in your local keychain. How do you get it, and more important you do make sure you get the proper one? (the id by itself is not enough). This is where the web of trust model of OpenPGP takes place. It would be too long to detail here but in short, ideally, you get access to the keys out of band and you have means to authentify it... or to authentify some other key of someone you know that itself has authentified the other key. And/Or you find it online in one or multiple places, secured by HTTPS (with a certificate and CA you trust), and ideally with DNSSEC.
If you have the public key, and you trust it to be good and not forged (and that typically it corresponds to the software developers of the tool you are trying to download), the above command show you that the .txt files has not been tampered with. And in turn this gives you the hash of all archives files, so you can download it and re-run the hash algorithm (SHA256 as written in the filename) and compare it with the value stored in file.
If someone had compromised the server and changed some archives it could, as you say yourself, as well change the .txt file with the new hashes so you could believe files do match.
However this third party would not be able to generate the proper .asc file with the PGP signature (upon gpg --verify you would get an error about invalid signature), because to do so he would need to have access to the private key which is supposedly properly secured and not stored on the webserver anyway.
And if it does generate it with another key you will see it because you will not trust this unknown key.
But of course the whole model collapses if the key itself is compromised.
| How does providing an asc file ensure I'm downloading the intended source code? |
1,481,718,407,000 |
I've used gpg for minimal things for years now (pass, yadm, etc.) and one thing I consistently have noticed is slow response times from the keyservers (mit, ubuntu, etc) when accessed through the web portals (searching takes absolutely forever).
Recently yay seems to have been having trouble importing keys with a No Name error that people seem to frequently encounter and the solution is always to just manually import the key. This has happened twice in the past week for me, with 1password and spotify. I tried researching long term solutions instead of the manual import shortcut and one suggestion was set the keyserver manually in /etc/pacman.d/gnupg/gpg.conf but that didn't resolve the problem. I ran pacman-key --refresh-keys and it worked, but it seemed incredibly error prone. Here's a snapshot of the output toward the end:
==> ERROR: Could not update key: B9113D1ED21E1A55
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 6D1A9E70E19DAA50
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 3A726C6170E80477
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 81AF739EC0711BF1
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: WARNING: unacceptable HTTP redirect from server was cleaned up
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: WARNING: unacceptable HTTP redirect from server was cleaned up
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: CF7037A4F27FB7DA
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 73B8ED52F1D357C1
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: EA6836E1AB441196
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 7FB1A3800C84C0A5
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: WARNING: unacceptable HTTP redirect from server was cleaned up
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: WARNING: unacceptable HTTP redirect from server was cleaned up
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: F9E712E59AF5F22A
gpg: error retrieving '[email protected]' via WKD: Connection refused
gpg: error reading key: Connection refused
gpg: error retrieving '[email protected]' via WKD: No name
gpg: error reading key: No name
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: C8880A6406361833
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: E711306E3C4F88BC
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 39E4F17F295AFBF4
gpg: WARNING: unacceptable HTTP redirect from server was cleaned up
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 097D629E437520BD
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 5CED81B7C2E5C0D2
gpg: error retrieving '[email protected]' via WKD: No data
gpg: error reading key: No data
gpg: error retrieving '[email protected]' via WKD: General error
gpg: error reading key: General error
gpg: refreshing 1 key from hkps://hkps.pool.sks-keyservers.net
gpg: keyserver refresh failed: No name
==> ERROR: Could not update key: 1F0CD4921ECAA030
gpg: key 4DC95B6D7BE9892E: "David Runge (Arch Linux Master Key) <[email protected]>" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
pub ed25519 2021-04-26 [SC]
2AC0A42EFB0B5CBC7A0402ED4DC95B6D7BE9892E
uid [ full ] David Runge (Arch Linux Master Key) <[email protected]>
sub cv25519 2021-04-26 [E]
gpg: key 25EA6900D9EA5EBC: "George Rawlinson <[email protected]>" 1 new signature
gpg: Total number processed: 1
gpg: new signatures: 1
pub ed25519 2016-11-03 [C]
034D823DA2055BEE6A6BF0BB25EA6900D9EA5EBC
uid [ unknown] George Rawlinson <[email protected]>
uid [ full ] George Rawlinson <[email protected]>
sub ed25519 2016-11-03 [S]
sub ed25519 2016-11-04 [A]
sub cv25519 2016-11-04 [E]
Is this always the case with gpg and keyservers? Are manual imports just a part of life? Why are these keyservers so unstable?
Please note: the Arch wiki suggests the following possible problems:
An outdated archlinux-keyring package.
Incorrect date.
Your ISP blocked the port used to import PGP keys.
Your pacman cache contains copies of unsigned packages from previous attempts.
dirmngr is not correctly configured
you have not upgraded in a long time and gpg/pacman does not handle that well
But I upgrade daily, my ISP has not blocked any ports (I can manually import), and my date is correct. I'm pretty sure I even recently cleared my pacman and yay caches (which seems like people actually recommend against). It seems like it's a problem with the spottiness of the keyservers themselves.
Am I wrong that it's the keyservers? If not, why are they so spotty? If I am wrong, what can I do to improve my pacman/yay experience to make this smoother and eliminate these pain points.
|
It’s possible that you’re running into keyserver issues, at least for some of the keyservers.
WKD is by nature unreliable, or at least unpredictable: it requires support in each domain from which you try to fetch keys, so it’s more likely to fail than to succeed for any given set of user ids (email addresses) from a variety of domains (as is the case in your example). There are domains with large numbers of OpenPGP users which support WKD (including Debian, Gentoo, and the Linux kernel), and in such contexts WKD can be expected to work.
The SKS pool is deprecated and shouldn’t be used. See sks-keyservers gone. What to use instead? for possible replacements.
In my experience keys.openpgp.org is reliable, but limited since it only serves keys from users who have confirmed their keys with that service. The MIT keyserver has had spotty availability for a long time.
In practice, for most users who end up needing OpenPGP keys for package verification, the most reliable keyservers are distribution keyservers, for those distributions which maintain their own keyservers (e.g. Debian or Ubuntu). These are nearly always reachable and functional; depending on their purpose they may only have distribution-related keys, but it’s always worth trying them.
| Are gpg keyservers always unreliable? |
1,481,718,407,000 |
I'm trying to add a kubernetes repo to my Amazon Linux 2 instance and struggle with automatically adding GPG keys.
This is my /etc/yum.repos.d/kubernetes.repo...
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
I then try to import the GPG keys:
~ # wget https://packages.cloud.google.com/yum/doc/yum-key.gpg \
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
~ # rpm --import *.gpg
However when I run any yum command it still doesn't know the keys:
# yum upgrade -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
kubernetes/signature | 454 B 00:00:00
Retrieving key from https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0xA7317B0F:
Userid : "Google Cloud Packages Automatic Signing Key <[email protected]>"
Fingerprint: d0bc 747f d8ca f711 7500 d6fa 3746 c208 a731 7b0f
From : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Retrieving key from https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
kubernetes/signature | 1.4 kB 00:00:00 !!!
https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes
Trying other mirror.
No packages marked for update
Even if I try to accept them manually it still doesn't work.
# yum upgrade
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
kubernetes/signature | 454 B 00:00:00
Retrieving key from https://packages.cloud.google.com/yum/doc/yum-key.gpg
Importing GPG key 0xA7317B0F:
Userid : "Google Cloud Packages Automatic Signing Key <[email protected]>"
Fingerprint: d0bc 747f d8ca f711 7500 d6fa 3746 c208 a731 7b0f
From : https://packages.cloud.google.com/yum/doc/yum-key.gpg
Is this ok [y/N]: y <<<<< Yes, I accept it!
Retrieving key from https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
kubernetes/signature | 1.4 kB 00:00:01 !!!
https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64/repodata/repomd.xml: [Errno -1] repomd.xml signature could not be verified for kubernetes
Trying other mirror.
No packages marked for update
How can I add the key so that YUM accepts it?
|
This is a known issue (see https://github.com/kubernetes/kubernetes/issues/60134).
Work around it by disabling GPG checks: set repo_gpgcheck=0 in /etc/yum.repos.d/kubernetes.repo.
Credits to drakedevel, who writes:
I think this is due to Amazon Linux 2 shipping an old version of GnuPG, and something about the repomd.xml.asc signature requires a newer version.
GnuPG 2.0.22 outright rejects the signature on the repository metadata with assuming bad signature from key BA07F4FB due to an unknown critical bit. I haven't been able to figure out what critical bit it's referring to -- there don't appear to be any on the signature or key -- but whatever GnuPG 2.0.22 is upset about is most likely the root cause.
This only affects the repomd signature, so there's zero reason to disable gpgcheck as several others have suggested. Disabling repo_gpgcheck is sufficient and preserves package signature verification (although it's still not an ideal workaround...)
| Yum in Amazon Linux 2 still asks for GPG key even after "rpm --import" when adding Kubernetes repo |
1,481,718,407,000 |
I have two PGP keys I use to sign and decrypt e-mails in kmail. When doing so, I have to enter the key's password (currently stored in KeePass).
Is it possible to save the passwords in my kwallet in a way that automatically unlocks the keys as needed? If so, how can this be achieved?
Edit: I have found something similar here, but for SSH keys rather than PGP keys. Maybe that can be adapted?
|
Unlocking
Is it possible to save the passwords in my kwallet in a way that
automatically unlocks the keys as needed? If so, how can this be
achieved?
As far as I know this cannot be done in kWallet. Use gpg-agent instead. You can make it's settings as liberal as you like, balanced between security and ease of access. Depending on which distribution you are running, the agent should work out of the box. Perhaps it's even already running in the background?
Other key management
I never used KeePass, so I don't know its features. However, kGPG might be worth looking at. It is a GUI front end to the system's GnuPG. Specifically, it also allows for low-ish level settings of GPG, including GPG agent.
GnuPG Settings
Here you can configure which gpg binary and which configuration file
and home folder are used. These values are autodetected on first start
and should already work.
Using the GnuPG agent makes work with GnuPG more comfortable as you do
not need to type in your password for every action. It is cached in
memory for a while so any operation that would require a password can
immediately be done. Note that this may allow other people to use your
private keys if you leave your session accessible to them.
kMail
The question also contains the kmail tag, so I will also elaborate on that. You might want to read the PGP configuration section and kmail FAQ, GnuPG section. If you have set up the keys using kGPG above, you don't have to be very worried about all the fat warning and the steps in the top part of the page. Just be informed about them.
Integration
Integration is actually happening implicit. kGPG just tells GnuPG which keys to create, modify, open and more actions. It lists in its interface what keys are on the system and their trust level etc. But in the background everything is stored in the ~/.gnupg directory in the GnuPG format. (I'm not sure if kGPG invokes GPG or is linked to GPG libraries, but the effect is the same)
kMail is just another kind of front end. It invokes the gpg command to access the keys stored in the same directory. For instance for signing, encrypting and decrypting.
The gpg-agent is session wide. Meaning, if you unlock a private key in kGPG, it will also be unlocked for kMail and visa versa.
Edit
I just found kwalletcli, which provides kwallet bindings for pinentry. My distribution does not provide a package, so at this moment I'm unable to try it out.
You might have to manually install the package if your distro does not support it as well.
Once again, arch wiki comes along and saves the day:
Tip: For using /usr/bin/pinentry-kwallet you have to install the
kwalletcli package.
~/.gnupg/gpg-agent.conf:
#pinentry interface with kdewallet
pinentry-program /usr/bin/pinentry-kwallet
Alternative
If you don't want to or can't install kwalletcli, you might be able to do some scripting using the kwallet-query command. You will have to have knowledge about which wallet to open to obtain the password. See man kwallet-query for more info.
However, gpg does not allow password input from STDIN by default, so you will need to configure gpg for it.
Note on ssh-agent
If you get gpg-agent to work properly, you can use it also as a ssh-agent.
example on Kubuntu 22.04 (Jellyfish) how use Keybase PGP keys with Git (auth & sign)
# setup Keybase where you're storing PGP keys in cloud
https://keybase.io/docs/the_app/install_linux
# Import the public key
keybase pgp export | gpg --import
# Import the private key
keybase pgp export -s | gpg --allow-secret-key-import --import
# show all keys
gpg --list-keys --with-keygrip
gpg --list-secret-keys --with-keygrip
# There should be 3 keys: one main [SC]==PUBKEY_USAGE_SIG&PUBKEY_USAGE_CERT and two subkeys [A]==PUBKEY_USAGE_AUTH && [E]==PUBKEY_USAGE_ENC
# Now you have to edit main one ([SC] ID) of them to "trust" it
gpg --edit-key PUT_[SC]_ID_HERE
key 0
trust
5
y
key 1
trust
5
y
key 2
trust
5
y
quit
echo 'enable-ssh-support' >> ~/.gnupg/gpg-agent.conf
echo 'pinentry-program /usr/bin/pinentry-kwallet' >> ~/.gnupg/gpg-agent.conf
gpg -K --with-keygrip
echo 'PUT_[A]_keygrip_ID_HERE' >> ~/.gnupg/sshcontrol
echo 'export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)' >> ~/.bashrc
echo 'gpgconf --launch gpg-agent' >> ~/.bashrc
# setup git configs & set your favorite editor
echo 'export VISUAL="vim"' >> ~/.bashrc
git config --global commit.gpgsign true
gpg --list-secret-keys --keyid-format=long
git config --global user.signingkey [SC]_sec_id
git config --global user.name "stackexchange"
git config --global user.email [email protected]
# reload terminal env & gpg-agent and check everything works
source ~/.bashrc
gpgconf --kill gpg-agent
ssh-add -L
ssh -T [email protected]
| Can I use kwallet to manage PGP keys? |
1,481,718,407,000 |
I would like to set the expiration date of a GPG subkey in the past, but gpg --edit-key does not allow me to. Is there any workaround to that?
Rationale: it is useful to set the expiration date of a subkey in the past in order to temporarily disable it. If you just revoke it, you lose the ability to enable it again later on.
|
A possible workaround is to use faketime to convince gnupg to not complain. See this other question:
$ faketime 'last week' gpg2 --edit-key ABCDEF12
and then use ordinary commands to expire the subkey tomorrow. That "tomorrow" will actually be six days ago.
| gnupg: set subkey expiration date in the past |
1,481,718,407,000 |
Emacs encrypts/decrypts .gpg files automatically. But recently I have lost the ability to decrypt files encrypted by the Linux gpg tool and vice versa.
I use:
passphrase symmetric encryption
gnupg 1.4.11
emacs 24.0.92.1
Debian sid
Decrypting using gpg (encrypted by emacs) gives:
gpg: decryption failed: bad key
Decrypting using emacs (encrypted by gpg) gives:
epa-file--find-file-not-found-function: Opening input file: Decryption failed,
Any idea how to avoid this?
|
The issue was in this (in Russian) solution which manipulates with input method. At present time it affects on passphrase during encryption/decryption.
| Emacs auto encryption and gpg |
1,481,718,407,000 |
I have quite some scripts that are still using the apt-key adv command. And I know this command is deprecated. And soon becoming unable to use.
Correct me if I'm wrong, but Debian 11 is the last Debian version supporting apt-key.
I also know we need to migrate to fetching the .asc file directly and put the file into the /etc/apt/trusted.gpg.d/ folder.
How do I convert from the command below to a wget of this .asc file? Where can I find the .asc files I need? Are those .asc files even provided by Linux Mint / X2Go or other repos?
The command I use for downloading keys at the moment is:
First example: apt-key adv --recv-keys --keyserver keyserver.ubuntu.com A6616109451BBBF2
Second example: apt-key adv --recv-keys --keyserver keyserver.ubuntu.com E1F958385BFE2B6E
How do I retrieve the .asc (or .gpg) files from those repos?
|
The apt-key-less equivalent to your apt-key adv command is
gpg --recv-keys --keyserver keyserver.ubuntu.com A6616109451BBBF2
gpg --export A6616109451BBBF2 | sudo tee /etc/apt/trusted.gpg.d/somenicename.gpg
This assumes that gpg is installed.
There’s no general rule regarding the availability of keyring files; if you have a download URL, you can use
sudo /usr/lib/apt/apt-helper download-file https://example.org/path/to/repokeyring.asc /etc/apt/trusted.gpg.d/repokeyring.asc
See Julian Klode’s Migrating away from apt-key post for details, and the section in the Debian 11 release notes on obsolete components:
bullseye is the final Debian release to ship apt-key. Keys should be managed by dropping files into /etc/apt/trusted.gpg.d instead, in binary format as created by gpg --export with a .gpg extension, or ASCII armored with a .asc extension.
| Migrating away from apt-key adv |
1,481,718,407,000 |
I have Lubuntu 16.04. My problem is similar to this questiuon:
sudo apt-get update
Get:1 http://it.archive.ubuntu.com/ubuntu xenial InRelease [247 kB]
Hit:2 http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu xenial InRelease
Hit:3 http://it.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:4 http://it.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:5 http://www.bchemnet.com/suldr debian InRelease
Hit:6 http://archive.canonical.com xenial InRelease
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [93,3 kB]
Fetched 340 kB in 6s (52,6 kB/s)
Reading package lists... Done
W: There is no public key available for the following key IDs:
FB510D557CC3E840
Non of answers provided is working:
According to answer #1 of this question:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FB510D557CC3E840
Executing: /tmp/tmp.oqit2axEyE/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys FB510D557CC3E840
gpg: requesting key 7CC3E840 from hkp server keyserver.ubuntu.com
gpgkeys: key FB510D557CC3E840 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: key not found
gpg: keyserver communications error: bad public key
gpg: keyserver receive failed: bad public key
Or this one from the same question, answer #2:
sudo apt-get install debian-keyring debian-archive-keyring
Reading package lists... Done
Building dependency tree
Reading state information... Done
debian-archive-keyring is already the newest version (2014.3).
debian-keyring is already the newest version (2016.01.20).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Or this one from the same question, answer #3:
sudo apt-get install debian-archive-keyring
Reading package lists... Done
Building dependency tree
Reading state information... Done
debian-archive-keyring is already the newest version (2014.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Or this one from the same question, answer #4:
for n in `ls /var/lib/apt/lists/*gpg`; do echo "$n" ; gpg --list-packets "$n" | grep FB510D557CC3E840; done
ls: cannot access '/var/lib/apt/lists/*gpg': No such file or directory
Or this one from the same question, answer #5:
sudo apt-get install debian-keyring debian-archive-keyring
Reading package lists... Done
Building dependency tree
Reading state information... Done
debian-archive-keyring is already the newest version (2014.3).
debian-keyring is already the newest version (2016.01.20).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Another try, answer #1 of this question:
gpg --keyserver keyserver.ubuntu.com:80 --recv-keys 7CC3E840
gpg: requesting key 7CC3E840 from keyserver.ubuntu.com:80
gpgkeys: no keyserver host provided
gpg: keyserver internal error
gpg: keyserver receive failed: keyserver error
answer number 2 of the same question:
sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 7CC3E840
gpg: WARNING: unsafe ownership on configuration file `/home/username/.gnupg/gpg.conf'
gpg: external program calls are disabled due to unsafe options file permissions
gpg: keyserver communications error: general error
gpg: keyserver receive failed: general error
to be sure there is no problem with permission:
ls -l ~/.gnupg/gpg.conf
-rw------- 1 username username 9398 mag 16 15:34 /home/username/.gnupg/gpg.conf
From last answer:
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv-keys 7CC3E840
Executing: /tmp/tmp.8iRzKu4RVN/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com --recv-keys 7CC3E840
gpg: requesting key 7CC3E840 from hkp server keyserver.ubuntu.com
gpgkeys: key 7CC3E840 not found on keyserver
gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: keyserver communications error: key not found
gpg: keyserver communications error: bad public key
gpg: keyserver receive failed: bad public key
|
The missing key is the key for the Samsung Unified Linux Driver Repository. Following the instructions added to the website yesterday should fix things:
wget http://www.bchemnet.com/suldr/pool/debian/extra/su/suldr-keyring_1_all.deb
sudo dpkg -i suldr-keyring_1_all.deb
(assuming you trust the repository of course!).
| Problem with public key on apt-get update |
1,481,718,407,000 |
I've been making my way through what's on the internet concerning gpg lately. And I must say it's pretty confusing.
Particularly, the importing/exporting part. When you generate a key, you basically get 4 keys by default. What are possible ways to export the keys (only one key, several keys at once)? What are possible ways to delete keys (the same)? Also, I'm now not sure, if I interpret gpg --list-keys, gpg --list-secret-keys results correctly. E.g., I seem to export only one key (subkey, gpg --export SUB_ID!), but when importing I get primary key as well.
|
What I've managed to find out. Correct me if I'm wrong.
There are public and private keys, they go in pairs. There are primary keys and each primary key can have one or more subkeys. By default, when you generate a key, you get four keys ((1) RSA and RSA (default)). One keypair for signing and certification (primary keys) and one keypair for encryption (subkeys). Also, there are two keyrings, for private and for public keys.
And now to the tricky part. I was experimenting with importing/exporting keys. For that I created a key with 2 subkeys. Then I exported it in different ways:
$ gpg --export PRI_ID > ~/_/export-1
$ gpg --export PRI_ID! > ~/_/export-2
$ gpg --export SUB_ID_1! > ~/_/export-3
$ gpg --export SUB_ID_2! > ~/_/export-4
$ gpg --export-secret-keys PRI_ID > ~/_/export-secret-keys-1
$ gpg --export-secret-keys PRI_ID! > ~/_/export-secret-keys-2
$ gpg --export-secret-keys SUB_ID_1! > ~/_/export-secret-keys-3
$ gpg --export-secret-keys SUB_ID_2! > ~/_/export-secret-keys-4
$ gpg --export-secret-subkeys PRI_ID > ~/_/export-secret-subkeys-1
$ gpg --export-secret-subkeys PRI_ID! > ~/_/export-secret-subkeys-2
$ gpg --export-secret-subkeys SUB_ID_1! > ~/_/export-secret-subkeys-3
$ gpg --export-secret-subkeys SUB_ID_2! > ~/_/export-secret-subkeys-4
And started exporting keys, and see what happens:
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-1; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-2; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-3; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-4; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-keys-1; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-keys-2; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-keys-3; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-keys-4; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-subkeys-1; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-subkeys-2; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-subkeys-3; gpg -k; gpg -K
$ gpg --delete-secret-key PRI_ID; gpg --delete-key PRI_ID; gpg --import ~/_/export-secret-subkeys-4; gpg -k; gpg -K
Here are my conclusions, which somewhat contradict what is in the manual pages:
`gpg --export PRI_ID` exports all public keys (3 keys)
`gpg --export PRI_ID!` exports primary public key (1 key)
`gpg --export SUB_ID!` exports public primary key and public subkey (2 keys)
`gpg --export-secret-keys PRI_ID` exports all 3 keypairs (6 keys)
`gpg --export-secret-keys PRI_ID!` exports primary keypair (2 key)
`gpg --export-secret-keys SUB_ID!` exports primary keypair and subkey keypair (4 keys)
gpg --export-secret-subkeys is like gpg --export-secret-keys, but doesn't export private primary key (or makes it useless as they say, sec#). Generally, PRI_ID, SUB_IDs are interchangeable, unless you put exclamation mark after them. But for --delete-key, --delete-secret-key they are interchangeable even with exclamation key.
UPD According to gpg --list-packets I seem to be wrong and there is no contradiction with man pages. --export-secret-keys must be exporting secret keys after all. It's just that a public key may be inferred from a private one.
However, there's one thing left after all. What kind of connection between primary keys and subkeys? Why when I export a subkey, I get primary key as well?
UPD Oh, and each keypair shares one and the same id.
| Which keys gpg exports and what is in the keyrings? |
1,481,718,407,000 |
I have a gpg setup started with older gpg versions and I did not use a passphrase back then. I would type enter directly when prompted for it. I'm not sure if that means the key isn't encrypted or if it is encrypted with an empty passphrase.
Regardless, when I try to decrypt something that was sent to me recently, gpg needs access to my private key and prompts me for a passphrase but now I cannot use an empty passphrase anymore. gpg fails with:
$ gpg -d foo.asc
(X dialog that prompts me for passphrase, I just press enter)
gpg: public key decryption failed: No passphrase given
gpg: decryption failed: No secret key
I would like to be able to use my keys again. I don't mind setting a passphrase from now on but I don't know how:
$ gpg --passwd [email protected]
(X dialog that prompts me for current passphrase, I just press enter)
gpg: key xxxxxxxxxxxxxxxx/aaaaaaaaaaaaaaaa: error changing passphrase: No passphrase given
gpg: key xxxxxxxxxxxxxxxx/bbbbbbbbbbbbbbbb: error changing passphrase: No passphrase given
gpg: error changing the passphrase for '[email protected]': No passphrase given
I am running gpg (GnuPG) 2.2.5 and libgcrypt 1.8.2 on openSUSE 15.0.
|
I solved this by using an older system which had the key.
I set a new passphrase on the old system where empty-passphrase input works.
Export old system private key and copy it over new system
Clean gpg state of new system (move .gnupg to .gnupg.bak)
Import the non-empty passphrase private key
Here are the commands I ran:
# put a non-empty passphrase on current key
me@old$ gpg --passwd [email protected]
(leave empty on first prompt)
(put a new non-empty passphrase on 2nd)
(confirm new passphrase)
# now we export it
me@old$ gpg --list-secret-keys
/home/xxxxx/.gnupg/secring.gpg
-------------------------------
sec 4096R/AAAAAAAA 2015-01-01
uid Foo Bar <[email protected]>
uid Bar Foo <[email protected]>
ssb 4096R/BBBBBBBB 2015-01-01
# I've used the first key id (should be 8 hex digits)
me@old$ gpg --export-secret-keys AAAAAAAA > priv.key
# copy key over new system
# backup .gnupg dir just in case
me@new$ mv .gnupg .gnupg.back
# import new priv key
me@new$ gpg --import priv.key
(type new passphrase set previously)
# done!
For completeness sake here are the software versions of both systems, maybe that can help someone:
New system (cannot input empty passphrase) software version:
gpg (GnuPG) 2.2.5
libgcrypt 1.8.2
pinentry-curses (pinentry) 1.1.0
Old system (can input empty passphrase) software version:
gpg (GnuPG) 2.0.24
libgcrypt 1.6.1
pinentry-curses (pinentry) 0.8.3
| gpg cannot unlock passphrase-less key: "gpg: public key decryption failed: No passphrase given" |
1,481,718,407,000 |
I'm trying to generate a GPG key on Ubuntu 16.10 and GPG is taking forever.
I googled a bit and found some websites, including some questions on StackExchange, suggesting to run an entropy generator like rngd to help the system generate random numbers faster.
Some of these websites also encouraged to check /proc/sys/kernel/random/entropy_avail, stating that, on their systems, it reported four-digit numbers before running GPG, and two to one-digit numbers while it was running.
I'm currently running GPG on my computer; it's been running for at least half an hour, and I'm getting this
$ cat /proc/sys/kernel/random/entropy_avail
3644
The number increases over time, and decreases very seldom by small amounts (after writing this sentence it's at 3801). I'm not running any random number generator. Actually, if I try to run one (e.g. sudo rngd -fr /dev/random, it drops to around 50; if I use /dev/urandom it stays around 3000).
Can anybody help me figure out what the hell is wrong with my system?
I'm on Linux 4.8.0-37-generic, gpg (GnuPG) 2.1.15, libgcrypt 1.7.2-beta.
|
I had a similar problem recently after upgrading to Debian 9. Some of the programs that depend on random numbers have had their source code/random generator routines changed in recent Linux versions that make them more dependent on the entropy of the system.
Installing the daemon haveged seems to provide a consistent pool of random numbers. So do it:
sudo apt-get install haveged
The haveged daemon is now required by disparate programs requiring entropy, especially in VMs and iOTs (e.g. raspberry, others) where the entropy is normally low.
From man haveged:
NAME
haveged - Generate random numbers and feed Linux's random device.
DESCRIPTION
haveged generates an unpredictable stream of random numbers harvested
from the indirect effects of hardware events on hidden processor state
(caches, branch predictors, memory translation tables, etc) using the
HAVEGE (HArdware Volatile Entropy Gathering and Expansion) algorithm.
The algorithm operates in user space, no special privilege is required
for file system access to the output stream.
Linux pools randomness for distribution by the /dev/random and
/dev/urandom device interfaces. The standard mechanisms of filling the
/dev/random pool may not be sufficient to meet demand on systems with
high needs or limited user interaction. In those circumstances, haveged
may be run as a privileged daemon to fill the /dev/random pool whenever
the supply of random bits in /dev/random falls below the low water mark
of the device.
| GPG key generator does *not* use entropy |
1,481,718,407,000 |
Is mandatory to use pinentry with gpg2?
Why is pinentry better over legacy prompt?
|
Yes, the use of a pinentry program is mandatory with GnuPG 2 and later.
This follows from the updated architecture in use nowadays:
GnuPG clients no longer deal with private key material, or with passphrases etc. (as far as possible — as far as I can tell, the only time a passphrase goes through the client is when you change it);
to support this, a separate process, the agent, stores private keys; it runs as a user-level daemon, started automatically when a client needs it;
the agent, being a daemon, doesn’t have an “owning” terminal, nor does it know how to obtain input from the user;
obtaining input from the user is delegated to a pinentry-compatible program of the user’s choice.
The use of a pinentry program ensures that your private key stays confined to the agent (if it knows about it at all of course), without your having to supply the private key and passphrase explicitly to the agent (as happens e.g. with ssh-add). It also ensures that the requests for your passphrase are consistent, regardless of the source of the request (the amount of security that that provides is as usual up for debate).
| About pinentry usage along with gpg |
1,481,718,407,000 |
Here's the scenario, we're using GnuPG to encrypt data between 2 web servers. 1 is on RHEL. GnuPG will be accessed through cgi scripts to encrypt and decrypt. So I need a keyring that the apache user has access to. This has proven to be difficult for me on Red Hat, I was able to get this set up pretty easily on Ubuntu. Here's what I've tried to, maybe someone has a better/easier way to accomplish this.
I became the apache user
su -s /bin/bash apache
when running
gpg --gen-key
it couldn't create the .gnupg directory at /var/www, so I created that and set the owner to apache.apache. now when generating keys, I get
can't connect to `/var/www/.gnupg/S.gpg-agent': No such file or directory
gpg-agent[26949]: command get_passphrase failed: Operation cancelled
gpg: cancelled by user
gpg: Key generation canceled.
so I created that file, after reading the man page a bit (and some googling)
mknod -m 700 S.gpg-agent p
now I get
can't connect to `/var/www/.gnupg/S.gpg-agent': Connection refused
gpg-agent[26949]: command get_passphrase failed: Operation cancelled
gpg: cancelled by user
gpg: Key generation canceled.
I haven't been able to get anywhere after this as I'm getting into areas I don't know much about. I'm assuming it has to do with that apache isn't really a user in the since of having a bash profile, etc. So where do I go from here?
|
Have you tried creating a new user and invoking the command with sudo instead? If fear this might be some permission issue and the easier way would be removing the agent node from /var/www to somewhere we know is accessible to the gpg user, maybe the /tmp directory. You can manually specify the agent node location changing the env variable GPG_AGENT_INFO.
| Creating a GnuPG keyring for apache |
1,481,718,407,000 |
I am transferring a key from one machine to another and do the following:
On Machine A:
% gpg --export-secret-key -a [username] > my_private.key
Please enter the passphrase to export the OpenPGP secret key:
"[username and other data like email]"
2048-bit RSA key, ID [removed-ID],
created 2015-11-09.
Passphrase:
Here I get an error when I type the known correct passphrase:
*** Bad Passphrase (try 2 of 3) ***
Please enter the passphrase to export the OpenPGP secret key:
"[username and other data like email]"
2048-bit RSA key, ID [removed-ID],
created 2015-11-09.
Passphrase:
So I do what I have found to work as a workaround during decryption as well: just press enter
gpg: key [removed-ID]: error receiving key from agent: No passphrase given - skipped
Please enter the passphrase to export the OpenPGP secret subkey:
"[username and other data like email]"
2048-bit RSA key, ID [removed-sub-ID],
created 2015-11-09 (main key ID [removed-ID]).
Passphrase:
And this time it works - both when decrypting and it "works" (doesn't throw an error) to export the key.
Now I have my_private.key on Machine A.
I SFTP the file over to Machine B - I leave out the details as I don't think this is where the problem is...
On Machine B:
$ gpg --import my_private.key
gpg: Total number processed: 0
$
Note: it said "0 processed". Why?
to be sure, I can do this:
$ gpg --list-secret-keys
$
What am I doing wrong?
Note
There may be 2 problems here:
Why the correct passphrase works only after getting past the first
"main key"?
Why the exported key won't import?
Update:
After a suggestion to try the obsolete option --allow-secret-key-import, I tried it and got the following:
$ gpg --allow-secret-key-import my_private.key
gpg: subkey w/o mainkey
gpg: standalone signature of class 0x18
gpg: Signature made Mon 09 Nov 2015 11:26:17 AM EST using RSA key ID [removed-ID]
gpg: invalid root packet for sigclass 18
gpg: Can't check signature: Invalid signature class
|
The attempt in the update I posted clued me in that there are actually 2 (private) keys at play here: a master and a subkey. They are different. This article helped me get that fact even more: https://wiki.debian.org/Subkeys
I still don't know how I got into a state where the master has a different password to access than the subkey, but apparently that is why skipping the master and using the changed password for the subkey works.
Luckily I still had the password for the master that I thought I had changed a while ago. Using that, I was able to export the key, move it, and import successfully.
| importing a gpg private key - will not import |
1,481,718,407,000 |
I received an file encrypted with the public key I generated but I can't get it to decrypt.
Steps:
gpg --gen-key default options
gpg --export -a <email> > pub.key
sent the pub.key
received the encrypted file
cat <file> | gpg
The error:
$ cat cred.gpg | gpg
gpg: key 71980D35: secret key without public key - skipped
gpg: encrypted with RSA key, ID 0D54A10A
gpg: decryption failed: secret key not available
However, the secret key DOES exist in my keyring and the public key i generate from it matches the fingerprint of the pub.key i sent to my coworker.
$ gpg --list-secret-keys
/home/jcope/.gnupg/secring.gpg
------------------------------
sec 2048R/71980D35 2016-03-04
uid me <email>
ssb 2048R/0D54A10A 2016-03-04
Checking the fingerprint
$ gpg --with-fingerprint pub.key
pub 2048R/AF0A97C5 2016-03-04 me <email>
Key fingerprint = 17A4 63BF 5A7D D3B2 C10F 15C0 EDD6 4D8A AF0A 97C5
sub 2048R/1103CA7C 2016-03-04
$ gpg --fingerprint | grep 17a4 -i
Key fingerprint = 17A4 63BF 5A7D D3B2 C10F 15C0 EDD6 4D8A AF0A 97C5
I'm a gpg newby and at a loss for why this isn't working. It seems like the most standard operation.
|
Note the error message: it doesn't say that the secret key is missing (it isn't), it says the public key is missing.
gpg: key 71980D35:secret key without public key- skipped
In RSA, some numbers (d, p, q, u) are private and others (n, e) are public. Only the 2 public numbers are required for encryption and signature verification while all 6 numbers are required in order to decrypt and sign. So for the latter operations, you actually need both the secret and public keys.
Did the public key get deleted from the pubring by accident?
You can try re-importing the public key. Since the public key is the one that is distributed widely, it should be easy to re-obtain a copy of it.
| gpg: "secret key not available" when sec & pub key are in keyring |
1,481,718,407,000 |
I am attempting to restore some files to an OpenSUSE 12.3 machine that was backed up with deja-dup (duplicity). When prompted for the password to decrypt the backup, I enter the correct password and I am prompted repeatedly with no progress.
The error given in /var/log/messages is:
The gnome keyring socket is not owned with the same credentials as the
user login: <username removed>
gkr-pam: couldn't unlock the login keyring
In deja-dup's debugging log I have:
DUPLICITY: ERROR 31 GPGError
DUPLICITY: . GPGError: GPG Failed, see log below:
DUPLICITY: . ===== Begin GnuPG log =====
DUPLICITY: . gpg: WARNING: "--no-use-agent" is an obsolete option - it has no effect
DUPLICITY: . gpg: CAST5 encrypted data
DUPLICITY: . gpg: encrypted with 1 passphrase
DUPLICITY: . gpg: decryption failed: Bad session key
DUPLICITY: . gpg: block_filter 0x7f969a828e60: read error (size=15648,a->size=15648)
DUPLICITY: . gpg: block_filter: pending bytes!
DUPLICITY: . ===== End GnuPG log =====
|
Install python-oauth to fix this problem.
| Gnome keyring issue |
1,481,718,407,000 |
Issue:
- The passphrase is repeatedly being requested when I pass show <name of credential>.
Doing some Googling, I found you can do that with gpg-preset-passphrase, however I'm not sure where to get it or if it included in the gpg distribution.
This is the current version of gpg I'm running.
Does anyone know how to get gpg-preset-passphrase installed?
gpg --version
gpg (GnuPG) 2.0.22
libgcrypt 1.5.3
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, ?, ?, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
|
Looks like it was installed but just not directly accessible through the gpg-preset-passphrase command, but rather: /usr/libexec/gpg-preset-passphrase:
/usr/libexec/gpg-preset-passphrase --version
gpg-preset-passphrase (GnuPG) 2.0.22
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
| gpg - gpg-preset-passphrase installation |
1,481,718,407,000 |
dirmngr is used by python-apt and is recommended by gnupg and gpgsm. I tried to shutdown dirmngr as shared in the manpage but got this -
└─[$] dirmngr -vv --shutdown
dirmngr[9494]: error opening '/home/shirish/.gnupg/dirmngr_ldapservers.conf': No such file or directory
Can somebody share how to shutdown it ? I tried --debug-level and other tricks but couldn't get it to shutdown. How do I shutdown dirmngr ?
Update -
[$] dpkg -l dirmngr
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============================-====================-====================-=================================================================
ii dirmngr 2.1.17-3 amd64 GNU privacy guard - network certificate management service
Think it is installed perfectly inspite of the errors -
[$] systemctl --user status dirmngr
● dirmngr.service - GnuPG network certificate management daemon
Loaded: loaded (/usr/lib/systemd/user/dirmngr.service; static; vendor preset: enabled)
Active: active (running) since Sun 2017-01-08 14:46:21 IST; 5h 47min ago
Docs: man:dirmngr(8)
Main PID: 1203 (dirmngr)
CGroup: /user.slice/user-1000.slice/[email protected]/dirmngr.service
└─1203 /usr/bin/dirmngr --supervised
Jan 08 14:46:40 debian dirmngr[1203]: DBG: chan_5 <- KEYSERVER --clear hkp://pgp.mit.edu
Jan 08 14:46:40 debian dirmngr[1203]: DBG: chan_5 -> OK
Jan 08 14:46:40 debian dirmngr[1203]: DBG: chan_5 <- KS_GET -- 0xDAD95197
Jan 08 14:46:40 debian dirmngr[1203]: DBG: dns: libdns initialized
Jan 08 14:46:50 debian dirmngr[1203]: DBG: dns: getsrv(_hkp._tcp.pgp.mit.edu): Server indicated a failure
Jan 08 14:46:50 debian dirmngr[1203]: command 'KS_GET' failed: Server indicated a failure <Unspecified source>
Jan 08 14:46:50 debian dirmngr[1203]: DBG: chan_5 -> ERR 219 Server indicated a failure <Unspecified source>
Jan 08 14:46:50 debian dirmngr[1203]: DBG: chan_5 <- BYE
Jan 08 14:46:50 debian dirmngr[1203]: DBG: chan_5 -> OK closing connection
Jan 08 14:46:50 debian dirmngr[1203]: handler for fd 5 terminate
|
systemctl --user stop dirmngr.socket
systemctl --user restart dirmngr.socket
| How to shutdown and restart dirmngr? |
1,481,718,407,000 |
I've been using GPG on WSL2 Debian for some time now and everything worked perfectly, but yesterday I started receiving an error about gpg signs when using git.
Trying to run echo "test" | gpg --clearsign, I receive the following message:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
test
gpg: signing failed: No such file or directory
gpg: [stdin]: clear-sign failed: No such file or directory
I tried the following to fix the problem:
Kill gpg-agent with gpgconf --kill gpg-agent and killall gpg-agent
Restart WSL2
Restart my host machine
Generate a new key, which gives me the same message as test sign
Create a gpg.conf file with no-tty option
Use chmod 700 on ~/.gnupg/private-keys-v1.d
I'm using gpg version 2.2.27 with libgcrypt 1.8.8.
|
Turns out that something overwrote my tty variable, which made gpg go crazy, because in my .zshrc I had exported GPG_TTY as $(tty). I managed to solve this issue with export GPG_TTY=`tty`.
Edit: After further investigation I found out that the fault lies within Powerlevel10k, for more info see this StackExchange thread.
| gpg: signing failed: No such file or directory |
1,481,718,407,000 |
I have the following in my ~/.bash_profile in order to try to make GPG work nicely:
export GPG_TTY="`tty`"
But when I open a new shell, I get the following:
$ echo $GPG_TTY
not a tty
However, if I then source ~/.bash_profile again it then works and contains something like /dev/pts/2.
Is there a way to make this work automatically when the shell is opened? Could it be that sourcing that file initially is done before the tty is allocated and, if so, is there a way of doing it later?
|
The GPG_TTY environment variable should hold the path to the TTY device for the current interactive shell. It would therefore make most sense to have this in one's ~/.bashrc file rather than in the ~/.bash_profile file, as the login shell (which parses the profile file) may in fact not be interactive under some circumstances.
Therefore, remove the setting of GPG_TTY from ~/.bash_profile and instead add it as
export GPG_TTY="$( tty )"
in your ~/.bashrc file.
In general, add session specific setup of interactive shells in ~/.bashrc and setup that is not session specific to the ~/.bash_profile file.
| How to make `tty` work in .bash_profile |
1,481,718,407,000 |
I want to use GPG for local encryption only, and after reading the man file, I'm doing the following in order to encrypt a whole directory:
I zip the directory with a password "zip -r -e foo foo", then I encrypt it with "gpg -c foo.zip" using a passphrase. Is this an elegant and secure way of encrypting directories? Am I using GPG's full cryptographic power? Are there better alternatives?
So there's no a way to encrypt a whole directory without zip it or tar it?
|
Is this an elegant and secure way of encrypting directories?
Elegant -- no. Secure -- as secure as gpg.
Am I using GPG's full cryptographic power?
Yes.
Are there better alternatives?
tar the directory first instead of zip. gpg compresses data anyway.
| Encrypting directories with gpg [duplicate] |
1,481,718,407,000 |
I followed
encrypted netrc file with gpg
tutorial.
I edited my
~/.profile
like this
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 is ls for ./gnupg
~/.gnupg$ ls
openpgp-revocs.d private-keys-v1.d pubring.kbx pubring.kbx~ random_seed trustdb.gpg
It does not work,when I restart my Ubuntu error pops up that I already have one gpg-agent running. How to check this and fix this?
eval `gpg-agent --daemon --no-grab $HOME/.gpg-agent-info`
gpg-agent: a gpg-agent is already running - not starting a new one
|
That tutorial is obsolete, and all you should add to your ~/.profile now is GPG_TTY=$(tty).
On a modern Ubuntu system, the GPG agent sockets are in /run/user/$UID/gnupg and systemd will start gpg-agent for you automatically when gpg runs and tries to access the agent socket.
To confirm this, gpgconf --list-dirs agent-socket will show you the path that it's using for the socket, and systemctl --user status gpg-agent should show the status of the already-running agent.
| How to get more gpg-agent info? |
1,481,718,407,000 |
I am followings instructions Install from Debian, Ubuntu, or Mint using the command line and GnuPG in making Tails, based on Debian, usb stick.
All steps done where the failure in the last line gpg: error reading key: public key not found, while expected output sig! 0x9C31503C6D866396 2015-02-03 Stefano Zacchiroli <[email protected]> to the command gpg --keyid-format 0xlong --check-sigs A490D0F4D311A4153E2BB7CADBB802B258ACD84F
masi@masi:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.7 (jessie)
Release: 8.7
Codename: jessie
masi@masi:~$ wget https://tails.boum.org/tails-signing.key
--2017-02-26 08:47:14-- https://tails.boum.org/tails-signing.key
Resolving tails.boum.org (tails.boum.org)... 204.13.164.188
Connecting to tails.boum.org (tails.boum.org)|204.13.164.188|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 459593 (449K) [application/pgp-keys]
Saving to: ‘tails-signing.key’
tails-signing.key 100%[=====================>] 448.82K 351KB/s in 1.3s
2017-02-26 08:47:17 (351 KB/s) - ‘tails-signing.key’ saved [459593/459593]
masi@masi:~$ gpg --import < tails-signing.key
gpg: key 58ACD84F: public key "Tails developers (offline long-term identity key) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
gpg: no ultimately trusted keys found
masi@masi:~$ su
Password:
root@masi:/home/masi# apt-get install debian-keyring
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libx265-79 linux-image-4.6.0-0.bpo.1-amd64 linux-image-4.7.0-0.bpo.1-amd64
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
debian-keyring
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 52.4 MB of archives.
After this operation, 58.0 MB of additional disk space will be used.
Get:1 http://ftp.fi.debian.org/debian/ jessie/main debian-keyring all 2015.04.10 [52.4 MB]
Fetched 52.4 MB in 35s (1,458 kB/s)
Selecting previously unselected package debian-keyring.
(Reading database ... 316032 files and directories currently installed.)
Preparing to unpack .../debian-keyring_2015.04.10_all.deb ...
Unpacking debian-keyring (2015.04.10) ...
Setting up debian-keyring (2015.04.10) ...
root@masi:/home/masi# gpg --keyring=/usr/share/keyrings/debian-keyring.gpg --export [email protected] | gpg --import
gpg: key 6D866396: public key "Stefano Zacchiroli <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
gpg: no ultimately trusted keys found
root@masi:/home/masi# gpg --keyid-format 0xlong --check-sigs A490D0F4D311A4153E2BB7CADBB802B258ACD84F
gpg: error reading key: public key not found
OS: Debian 8.7
Hardware: Asus Zenbook UX303UB
|
You haven't imported the Tails key that you try to check the signatures on:
$ gpg --recv-key A490D0F4D311A4153E2BB7CADBB802B258ACD84F
$ gpg --check-sigs A490D0F4D311A4153E2BB7CADBB802B258ACD84F
pub rsa4096 2015-01-18 [C] [expires: 2018-01-11]
A490D0F4D311A4153E2BB7CADBB802B258ACD84F
uid [ unknown] Tails developers (offline long-term identity key) <[email protected]>
sig! 9C31503C6D866396 2015-02-03 Stefano Zacchiroli <[email protected]>
sig!3 DBB802B258ACD84F 2015-09-27 Tails developers (offline long-term identity key) <[email protected]>
sig!3 DBB802B258ACD84F 2016-08-30 Tails developers (offline long-term identity key) <[email protected]>
sig!3 DBB802B258ACD84F 2015-01-18 Tails developers (offline long-term identity key) <[email protected]>
uid [ unknown] Tails developers <[email protected]>
sig!3 DBB802B258ACD84F 2015-09-27 Tails developers (offline long-term identity key) <[email protected]>
sig!3 DBB802B258ACD84F 2016-08-30 Tails developers (offline long-term identity key) <[email protected]>
sub rsa4096 2015-01-18 [S] [expires: 2018-01-11]
sig! DBB802B258ACD84F 2016-08-30 Tails developers (offline long-term identity key) <tails@bgpg: 9 good signatures
gpg: 1124 signatures not checked due to missing keys
oum.org>
sub rsa4096 2015-01-18 [S] [expires: 2018-01-11]
sig! DBB802B258ACD84F 2016-08-30 Tails developers (offline long-term identity key) <[email protected]>
sub rsa4096 2016-08-30 [S] [expires: 2018-01-11]
sig! DBB802B258ACD84F 2016-08-30 Tails developers (offline long-term identity key) <[email protected]>
Well, you did, but you did it as an ordinary user, while trying to check the signature as root. You now have two keyrings, one with the Tails key in your user account, and one with the Debian developer's key in the root account.
This is one of the reasons you should use sudo and very seldom find yourself with an interactive root shell.
| Why this Debian-ex-developer public key not found? |
1,481,718,407,000 |
I'm running something like this:
find . -maxdepth 1 -type f -note -iname "*.gpg" | sort | while read file ; do
echo "Encrypting $file..."
gpg --trust-model always --recipient "[email protected]" --output "$file.gpg" \
--encrypt "$file" && rm "$file"
done
This runs great, but it seems that GPG is not optimized to use multiple cores for an encryption operation. The files I'm encrypting are about 2GB in size and I have quite a bit of them. I'd like to be able to run X jobs in parallel to encrypt the files and then remove them. How can I do this, setting a limit to, say, 8 jobs at a time?
|
If you install the GNU Parallel tool you can make pretty easy work of what you're trying to accomplish:
$ find . -maxdepth 1 -type f -note -iname "*.gpg" | sort | \
parallel --gnu -j 8 --workdir $PWD ' \
echo "Encrypting {}..."; \
gpg --trust-model always \
--recipient "[email protected]" --output "{}.gpg" \
--encrypt "{}" && rm "{}" \
'
details
The above is taking the output of find and running it through to parallel, and running 8 at a time. Everywhere there's an occurrence of {} the filenames that are being passed through from find will replace the {} in those spots.
References
Running shell script in parallel
| Running up to X commands in parallel |
1,481,718,407,000 |
I run mutt in tmux and when I run gpg to sign or encrypt, gpg shows a blank screen where I would expect to type my passphrase. I've straced gpg and it shows that it's hanging waiting on a socket read() (presumably from gpg-agent. What's going on here?
|
Short answer
If you are using bash, then Chris W.’s wrapper script is the way to go. If perchance you are using zsh, then you can exploit the ~/.zshenv startup script to set GPG_TTY from there, no need for a wrapper. Since bash does not have a similar startup script (cf. Bash Startup Files), you’ll have to use the wrapper there.
export GPG_TTY=${TTY}
Some background: Interactive and non-interactive shells
The gpg-agent expects GPG_TTY to point to the tty from where it is invoked, such that it can display its passphrase prompts in a secure manner. The GnuPG manual suggests putting the following in ~/.bashrc (or similar):
GPG_TTY=$(tty)
export GPG_TTY
If you invoke mutt directly from your shell, this will work: GPG_TTY will be set, mutt will pick it up and pass it to gpg when it needs to.
However, when you launch mutt via tmux’s new-window command or similar constructs, there is an important difference: Before, your mutt was in a so-called interactive shell—that is, you had a shell prompt open and launched mutt from there yourself. tmux new-window launches a non-interactive shell, since your shell is only needed to launch mutt and you won‘t be able to interact with it. In this case, bath won‘t read .bash_profile or .bashrc at all, since they are designed to set up your shell for interactive use.
zsh does pretty much the same thing: .zshrc is read for interactive shells and skipped for non-interactive ones. However, in zsh, you can supply a third startup file, .zshenv, that is read for every shell, no matter whether it is interactive or not. Therefore, if you set GPG_TTY from there, it will always be available, no matter in which way mutt is started. And since $TTY is a shell builtin variable that always points to the current tty, you can avoid the overhead of spawning a tty process every time the shell comes up.
| Why does mutt hang when running gpg in tmux? |
1,481,718,407,000 |
I have my /root mounted as read-only.
I have a script that sends an encrypted email using gpg;
something like the following:
echo "hello" | gpg --no-verbose -e -a -r [email protected] | mail [email protected]
But I get an error:
gpg: failed to create temporary file `/root/.gnupg/.#dkflsfj': Read-only file system
How can I tell gpg not to use temporary files?
I found an option use-temp-files in the man page:
use-temp-files
On most Unix-like platforms,
GnuPG communicates with the keyserver helper program via pipes,
which is the most efficient method.
This option forces GnuPG to use temporary files to communicate.
On some platforms (such as Win32 and RISC OS), this option is always enabled.
I don't have this option enabled in my config.
Apparently, it is set by default.
Is there any way I could "negate" this option?
The option no-use-temp-files does not seem to have any effect:
echo "asdf" | gpg --keyserver-options no-use-temp-files -e -a -r [email protected]
I still get the same error: gpg: failed to create temporary file `/root/.gnupg/.#jkfjg': Read-only file system,
and if I say --no-use-temp-files,
I get an error: gpg: Invalid option "--no-use-temp-files".
Is there any other way to fix this problem?
|
I solved the problem by using --lock-never option, which prevents gpg to attempt to lock the file.
| gpg uses temporary files instead of pipe |
1,481,718,407,000 |
I have a very (read: very) strong passphrase for my private key. How reckless can I be with my .gpg directory? Put another way, how many bits of entropy would I need in my passphrase to safely post my .gpg directory on the web? Put yet another way, how strong is the encryption algorithm protecting my secret key?
|
This is not a statement about the security of public key pairs or gpg encryption, but WRT entropy and passwords, given a password taken from the range of ASCII alphanumeric characters (A-Z, a-z, 0-9), the possible number of combinations in 16 characters is:
n = 62^16 = 47672401706823533450263330816
If I have your key and try to "brute force" the password by peeling through all those possibilities, 1 million times per second, then:
n / 1000000 / 3600 / 8760 = 1511681941489838
3600 being the number of seconds in an hour and 8760 being the number of hours in a year, it could, as a worst case scenario, take more than 1.5e13 centuries (1.5 million aeons).
Which is why it is very naive to believe that anyone tries to break a password that way. Passwords are important and strong passwords are better than weak passwords, but having "a very (read: very) strong passphrase" is not going to protect you any better from attempts to steal the password, spoof exchanges, or other methods which are not simply about brute forcing the passphrase. An analogy might be cancer -- there are people who've never smoked, eat well, exercise, always wear sunscreen, etc., and still get cancer. That doesn't mean you might as well run out and eat plutonium.
| If I have a really strong passphrase for my gpg private key, how reckless can I be with my .gpg directory? |
1,320,296,561,000 |
I read a lot of articles about using gpg to encrypt email, but I would like to use it to encrypt some files - mainly a bunch of *.isos. I'm going to describe what I thought I would do, so you can shoot me or just add some suggestions.
I'm going to do
tar -cvjf myiso.iso.tar.bz2 myiso.iso
and them I plan to encrypt this myisio.tar.bz2, using a key generated by gpg (don't know exactly how to do that. I'm going to read the man page). Them, I'm going to save this generated gpg key I used for this encryption in a flash drive, and encode this key itself with a symetric key.
Is it to insane?
|
You can use GPG to symmetrically encrypt a file with a passphrase (gpg -c). If the passphrase has enough entropy, you don't need an extra step of generating a secret key. What does “enough entropy” mean? Your encryption needs to withstand offline attacks, where the attacker can make cracking attempts as fast as his hardware allows it. With a small PC farm, the attacker might be able to make a couple hundred billion attempts per second, which is roughly 2^69 per decade. So with an entropy of 2^70 you'll be safe. That means if your passphrase consists of completely random letters (lower or upper case) and digits, it should be 12 characters long.
Now to store that passphrase, you can use GPG with its usual key pairs. Use gpg --gen-key to generate a key pair, and gpg -e to encrypt the passphrase used to encrypt the large file for one or more key pairs.
Here's a sketch on how to do the encryption (note that I avoid putting the passphrase on the command line or in the environment, so as to make sure another user can't find it by looking at the ps output while the command is running):
passphrase=$(pwgen -s 12 -1)
echo "The passphrase for myiso.iso.gpg is: $passphrase" |
gpg -e -r somebody -r somebodyelse >passphrase.gpg
echo "$passphrase" | gpg -c --passphrase-fd 3 3<&0 <myiso.iso >myiso.iso.gpg
and how to decrypt:
passphrase=$(gpg -d <passphrase.gpg)
echo "$passphrase" | gpg -d --passphrase-fd 3 3<&0 <myiso.iso.gpg >myiso.iso
The reason to use a passphrase (a shared secret) rather than directly encrypt is that it allows the file to be shared between several people. Only the small passphrase needs to be reencrypted if you want to add a recipient (removing a recipient only makes sense if you know the recipient hasn't had access to the plaintext and requires reencoding the ciphertext anyway).
| Encrypt files using gpg (and them symetric encrypting the key) - is it a normal thing to do in the *nix world? |
1,320,296,561,000 |
Using the GNU Privacy Guard (GnuPG): for some given key, say 0xDEADBEEF, how can a user readily list only the public keys in their keyring that have a UID that has been signed by that key?
It would be helpful if you could specify whether your answer is intended for use with GnuPG Modern (2.1.x), GnuPG Stable (2.0.x), or GnuPG Classic (1.4.x).
|
As far as I am aware there is no such option. Yet, it is trivial to script one together:
#!/bin/sh
KEY=${1:-'C840C4F6'} # that's my key
gpg -k |
grep 'pub ' |
cut -d ' ' -f 4 |
cut -d / -f 2 |
while read x; do
if gpg --list-sigs "$x" | grep C840C4F6 >/dev/null; then
echo "$x"
fi
done
And, thanks to the fact that GnuPG is pretty quick, it runs fast enough. With >300 keys that runs in less than a second on a cheap VPS.
Both -k and --list-sigs are very old gpg options. I've tested this only on 2.0 and 2.1, yet, I'm confident it will work on 1.4.
| List all keys signed by a given key |
1,320,296,561,000 |
I'm trying to understand what happens when verifying a detached gpg signature.
Here's an example from the gnupg manual:
blake% gpg --verify doc.sig doc
gpg: Signature made Fri Jun 4 12:38:46 1999 CDT using DSA key ID BB7576AC
gpg: Good signature from "Alice (Judge) <[email protected]>"
How does gpg determine that the signature is a good one? Does the signature contain a hash of the file which was signed? If so, how do you extract that hash from the signature itself?
I tried gpg --list-packets <signature> but it doesn't seem to show full information.
|
You can use the --list-packets option to get a dump of what's in a gpg file. The description of the file format is RFC 4880 (OpenPGP standard).
The signature does not directly contain a hash. It contains information that allows verifying both the hash and the sender: there is a signature verification algorithm, which takes a hash value and a public key as input, and returns yes or no; the algorithm returns yes if the signature was made by the private key corresponding to the given public key from a message with the given private key, and returns no in all other circumstances (signature of a different hash, signature made by a different key, or a bunch of bytes that can't be a signature at all). Under the DSA algorithm, I think it's infeasible to extract the hash from a signature if you don't have the private key.
The signature file contains the identity of the signer as well as the signature value. To verify the signature, gpg reads the signer's public key from your keyring, calculates the hash of the data, and applies the signature verification algorithm.
| What happens when you verify a detached signature? |
1,320,296,561,000 |
Running Ubuntu 16.04.4 LTS.
On running sudo apt update, the final lines are as follows:
W: GPG error: http://download.opensuse.org/repositories/home:/osmc/xUbuntu_16.04 Release: The following signatures were invalid: KEYEXPIRED 1482381670
E: The repository 'http://download.opensuse.org/repositories/home:/osmc/xUbuntu_16.04 Release' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
apt-key list shows one key expired:
pub 2048R/70F1BBEA 2014-10-14 [expired: 2016-12-22]
uid home:osmc OBS Project <home:[email protected]>
(For some reason, apt-key list | grep “expired:” returns nothing however.)
Attempting to update this key does not change anything:
$ apt-key adv --keyserver keys.gnupg.net --recv-keys 70F1BBEA
Executing: /tmp/tmp.pOcDAzqSkJ/gpg.1.sh --keyserver
keys.gnupg.net
--recv-keys
70F1BBEA
gpg: requesting key 70F1BBEA from hkp server keys.gnupg.net
gpg: key 70F1BBEA: "home:osmc OBS Project <home:[email protected]>" not changed
gpg: Total number processed: 1
gpg: unchanged: 1
I also tried running Y PPA Manager and "Try to import all missing GPG keys" but the result was the same.
I'm guessing perhaps I'm running an out-of-date version of Opensuse and need to change it, but I'm uncertain of what it is and how to do this correctly.
|
After adding a third party repository to a /etc/apt/sources.list.d/* file or /etc/apt/sources.list, you need to make sure the corresponding gpg key is inserted into the apt keystore.
wget http://download.opensuse.org/repositories/home:/osmc/xUbuntu_16.04/Release.key -O - | sudo apt-key add -
sudo apt update
If that doesn't work because the key really expired, remove the error and warning messages. Open /etc/apt/sources.list.d/osmc-installer.list and add a hash character ( # ) at the beginning of the lines before deb to turn them into comments.
sudo nano /etc/apt/sources.list.d/osmc-installer.list
Press the keyboard combination Ctrl+O and after that press Enter to save the file being edited. Press the keyboard combination Ctrl+X to exit nano.
Update your list of available software packages.
sudo apt update
| KEYEXPIRED on Opensuse repository |
1,320,296,561,000 |
I have some content that needs to be checked against a predetermined whitelist of OpenPGP (also keyword: gpg) public keys for a valid signature by one of them.
The whitelist is maintained separately. Ideally it would be a concatenation of ascii-armored public key blocks, but a directory with one public key per file would be fine. Because the whitelist is maintained separately, we don't want to use any of gpg's keyring management functionality. If the content is signed by a key in our set of keys, it passes. No different trust levels, no web of trust, etc.
Ideally we would have a program with an interface like this:
some-program KEYS_FILE CONTENT SIGFILE
or, with example arguments,
some-program /etc/ourapp/ourapps_trusted_pubkeys.asc /var/lib/ourapp/newcontent.tar.gz /var/lib/ourapp/newcontent.tar.gz.asc
The quickest way to do this with gpg seems to be:
use a temporary file as its keyring
point gpg to this using --keyring, but also give --no-default-keyring
iterate through the keys in ourapps_trusted_pubkeys.asc, importing them one at a time
iterate through the keys again, setting them to trusted with gpg --import-ownertrust
run the gpg --verify
This is a huge amount of effort for what I imagine to be a common use case. What am I missing? Does a tool similar to the postulated some-program(1) exist?
|
The program gpgv / gpgv2 is used for simple checking of signatures. The problem is that exported key files are not recognized as keyring. Thus you have to create a keyring in the first step:
cd /some/tmp/dir || exit 1
test -f pubring.gpg && { rm -f pubring.gpg || exit 1; }
gpg --no-options --no-default-keyring --keyring ./pubring.gpg \
--secret-keyring ./secring.gpg --import /etc/ourapp/ourapps_trusted_pubkeys.asc
Now /some/tmp/dir/pubring.gpg is a keyring file gpgv can use:
gpgv --keyring /some/tmp/dir/pubring.gpg \
/var/lib/ourapp/newcontent.tar.gz.asc /var/lib/ourapp/newcontent.tar.gz
If the data file path is the signature path without .asc (like in your example) then you can leave it out.
| how to check openpgp (gpg) signature against a set of public key blocks |
1,320,296,561,000 |
How to verify that the CHECKSUM file for the CentOS 8 ISO is real?
Download check sum and key:
$ wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
$ wget http://www.gtlib.gatech.edu/pub/centos/8.0.1905/isos/x86_64/CHECKSUM
$ wget http://www.gtlib.gatech.edu/pub/centos/8.0.1905/isos/x86_64/CHECKSUM.asc
Verify Key:
$ gpg RPM-GPG-KEY-CentOS-Official
gpg: WARNING: no command supplied. Trying to guess what you mean ...
pub rsa4096 2019-05-03 [SC]
99DB70FAE1D7CE227FB6488205B555B38483C65D
uid CentOS (CentOS Official Signing Key) <[email protected]>
Assert that the fingerprint matches https://www.centos.org/keys/
import key:
$ gpg --import RPM-GPG-KEY-CentOS-Official
gpg: key 05B555B38483C65D: public key "CentOS (CentOS Official Signing Key) <[email protected]>" imported
gpg: Total number processed: 1
gpg: imported: 1
Cannot verify the CHECKSUM file:
$ gpg --verify CHECKSUM.asc
gpg: Signature made Mon 23 Sep 2019 07:24:37 AM EDT
gpg: using RSA key 05B555B38483C65D
gpg: Good signature from "CentOS (CentOS Official Signing Key) <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
gpg: WARNING: not a detached signature; file 'CHECKSUM' was NOT verified!
It says:
gpg: WARNING: not a detached signature; file 'CHECKSUM' was NOT verified!
|
You don't need both CHECKSUM and CHECKSUM.asc. The latter is GPG-signed version of CHECKSUM. GPG is confused because it assumes that if you have somefilename and somefilename.asc, that the .asc file is a detached signature.
If you delete the file CHECKSUM, then you can gpg --verify CHECKSUM.asc and get:
gpg: Signature made Mon 23 Sep 2019 07:24:37 AM EDT
gpg: using RSA key 0x05B555B38483C65D
gpg: Good signature from "CentOS (CentOS Official Signing Key) <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
| How to verify checksum file of centos 8? |
1,320,296,561,000 |
I'm using Arch Linux Linux uplink 4.14.56-1-lts #1 SMP Tue Jul 17 20:11:42 CEST 2018 x86_64 GNU/Linux. I'm trying to solve a problem I'm currently have with GnuPG 2.2.9 (libgcrypt 1.8.3), but I've noticed I have these errors showing up all the time, for any operation I perform with gpg:
gpg: bad data signature from key 8975BA8B6100C6B1: Wrong key usage (0x19, 0x2)
gpg: bad data signature from key DEA16371974031A5: Wrong key usage (0x19, 0x2)
...so I'm not sure if that could be interfering with my other problem: signing Git commits and getting gpg failed to sign the data failed to write commit object.
This is the list of public/private keys that I have:
[gorre@uplink ~]$ gpg --list-keys
gpg: bad data signature from key 8975BA8B6100C6B1: Wrong key usage (0x19, 0x2)
gpg: bad data signature from key DEA16371974031A5: Wrong key usage (0x19, 0x2)
/home/gorre/.gnupg/pubring.kbx
------------------------------
pub rsa4096 2015-07-21 [SC] [expires: 2019-07-21]
94AE36675C464D64BAFA68DD7434390BDBE9B9C5
uid [ unknown] Colin Ihrig ...
sub rsa4096 2015-07-21 [E] [expires: 2019-07-21]
pub rsa4096 2014-04-01 [SCEA] [expires: 2024-03-29]
FD3A5288F042B6850C66B31F09FE44734EB7990E
uid [ unknown] Jeremiah Senkpiel ...
uid [ unknown] keybase.io/fishrock ...
sub rsa4096 2014-04-01 [SEA] [expires: 2024-03-29]
pub rsa4096 2014-11-10 [SCEA]
71DCFD284A79C3B38668286BC97EC7A07EDE3FC1
uid [ unknown] keybase.io/jasnell ...
uid [ unknown] James M Snell ...
uid [ unknown] James M Snell ...
sub rsa2048 2014-11-10 [S] [expires: 2022-11-08]
sub rsa2048 2014-11-10 [E] [expires: 2022-11-08]
pub rsa2048 2013-11-18 [SC]
DD8F2338BAE7501E3DD5AC78C273792F7D83545D
uid [ unknown] Rod Vagg ...
uid [ unknown] Rod Vagg ...
sub rsa2048 2013-11-18 [E]
pub rsa4096 2016-01-12 [SC]
C4F0DFFF4E8C1A8236409D08E73BC641CC11F4C8
uid [ unknown] Myles Borins ...
uid [ unknown] Myles Borins ...
uid [ unknown] Myles Borins ...
uid [ unknown] Myles Borins (Not used after January 2017) ...
sub rsa2048 2016-01-12 [E] [expires: 2024-01-10]
sub rsa2048 2016-01-12 [SA] [expires: 2024-01-10]
pub rsa4096 2015-12-17 [SC] [expires: 2019-12-17]
B9AE9905FFD7803F25714661B63B535A4C206CA9
uid [ unknown] Evan Lucas ...
uid [ unknown] Evan Lucas ...
sub rsa4096 2015-12-17 [E] [expires: 2019-12-17]
pub rsa4096 2016-04-07 [SC]
8FCCA13FEF1D0C2E91008E09770F7A9A5AE15600
uid [ unknown] Michaël Zasso (Targos) ...
sub rsa4096 2016-04-07 [E]
pub rsa4096 2016-10-07 [SC]
77984A986EBC2AA786BC0F66B01FBB92821C587A
uid [ unknown] Gibson Fahnestock ...
sub rsa4096 2016-10-07 [E]
pub rsa4096 2018-06-12 [SC]
B1BEB985FA77CDF913E2EAE88E0DCA371CC3F4EC
uid [ultimate] Gorre ...
sub rsa4096 2018-06-12 [E]
[gorre@uplink ~]$ gpg --list-secret-keys
/home/gorre/.gnupg/pubring.kbx
------------------------------
sec rsa4096 2018-06-12 [SC]
MY_SECRET_KEY
uid [ultimate] Gorre ...
ssb rsa4096 2018-06-12 [E]
UPDATE
Looks like my initial issue was somehow with the gpg-agent; I ended up configuring $HOME/.gnupg/gpg-agent.conf as:
[gorre@uplink ~]$ nano ~/.gnupg/gpg-agent.conf
max-cache-ttl 86400
default-cache-ttl 86400
default-cache-ttl-ssh 86400
max-cache-ttl-ssh 86400
# Run pacman -Ql pinentry | grep /usr/bin/ for more options, I'm using Gnome 2.x
pinentry-program /usr/bin/pinentry-gnome3
[gorre@uplink ~]$ gpg-connect-agent reloadagent /bye
...and everything works fine now – for what I wanted. Still, those errors are there, every time I execute the gpg command, but it looks like it doesn't impact the functionality of gpg – to the extent of what I do with it.
|
I solved this by editing my key and adding the "Signing" usage to the subkey which was encrypt-only.
First edit the key:
> gpg --edit-key "<my@email>"
gpg (GnuPG) 2.2.10; Copyright (C) 2018 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.
gpg: bad data signature from key ZZZZZZZZZZZZZZZZ: Wrong key usage (0x19, 0x2)
Secret key is available.
sec rsa4096/XXXXXXXXXXXXXXXX
created: YYYY-MM-DD expires: never usage: SCEA
trust: ultimate validity: ultimate
ssb rsa2048/YYYYYYYYYYYYYYYY
created: YYYY-MM-DD expires: YYYY-MM-DD usage: S
ssb rsa2048/ZZZZZZZZZZZZZZZZ
created: YYYY-MM-DD expires: YYYY-MM-DD usage: E
[ultimate] (1). My Name <my@email>
The subkey that gpg was complaining about bad signing from was ZZZZZZZZZZZZZZZZ, the second key, and indeed, that one was encrypt-only (usage: E), so I added Signing to that one:
gpg> key 2
sec rsa4096/XXXXXXXXXXXXXXXX
created: YYYY-MM-DD expires: never usage: SCEA
trust: ultimate validity: ultimate
ssb rsa2048/YYYYYYYYYYYYYYYY
created: YYYY-MM-DD expires: YYYY-MM-DD usage: S
ssb* rsa2048/ZZZZZZZZZZZZZZZZ
created: YYYY-MM-DD expires: YYYY-MM-DD usage: E
[ultimate] (1). My Name <my@email>
gpg> change-usage
Changing usage of a subkey.
Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions: Encrypt
(S) Toggle the sign capability
(E) Toggle the encrypt capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? s
Possible actions for a RSA key: Sign Encrypt Authenticate
Current allowed actions: Sign Encrypt
(S) Toggle the sign capability
(E) Toggle the encrypt capability
(A) Toggle the authenticate capability
(Q) Finished
Your selection? q
sec rsa4096/XXXXXXXXXXXXXXXX
created: YYYY-MM-DD expires: never usage: SCEA
trust: ultimate validity: ultimate
ssb rsa2048/YYYYYYYYYYYYYYYY
created: YYYY-MM-DD expires: YYYY-MM-DD usage: S
ssb* rsa2048/ZZZZZZZZZZZZZZZZ
created: YYYY-MM-DD expires: YYYY-MM-DD usage: SE
[ultimate] (1). My Name <my@email>
Lastly, save the changes:
gpg> save
FWIW I used keybase a few years ago to generate this keypair, and I'm no gpg expert, so I don't know if this is the "proper" way to solve the issue, but it worked for me. Also, in the interests of full disclosure, there were actually two subkeys which were encrypt-only and I added Signing to both of them, but I edited the transcript above to make it clearer. YMMV.
| How to solve gpg: bad data signature from key: KEY_ID Wrong key usage (0x19, 0x2) |
1,320,296,561,000 |
Take the following command (real example) :
~$ gpg --edit-key [email protected] showpref quit
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
Piping the output into a | grep doesn't work :
~$ gpg --edit-key [email protected] showpref quit | grep Compression
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
Is there a way to make that work ? E.g., the result I'd like to get is :
~$ gpg --edit-key [email protected] showpref quit | grep Compression
Compression: ZLIB, BZIP2, ZIP, Uncompressed
~$
[EDIT : what I tried so far ] :
@steeldriver, @RomeoNinov : I don't think redirecting stderr is going to do the trick. It doesn't look like gpg's output goes to stderr.
Basically, gpg is an interactive command, but launching gpg ... cmd1 cmd2 makes it non-interactive (e.g., gpg ... showpref quit is the same as doing interactively showpref followed by quit in gpg's shell).
@steeldriver :
~$ gpg --edit-key [email protected] showpref quit 2> >(grep Compression)
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
@RomeoNinov :
~$ gpg --edit-key [email protected] showpref quit 2>&1| grep Compression
(...)
[ultimate] (1). Foo Bar <[email protected]>
Cipher: AES256, AES192, AES, CAST5, 3DES
AEAD:
Digest: SHA256, SHA1, SHA384, SHA512, SHA224
Compression: ZLIB, BZIP2, ZIP, Uncompressed
Features: MDC, AEAD, Keyserver no-modify
Preferred keyserver: ldap://keyserver.pgp.com
~$
|
The solution is to use --batch. This will help gpg to send info to standard file handlers.
# gpg --batch --edit-key [email protected] showpref quit 2>&1 |grep Com
Compression: ZLIB, BZIP2, ZIP, Uncompressed
| Is it possible to grep this output from gpg |
1,320,296,561,000 |
I have downloaded Debian installation iso from http://cdimage.debian.org/debian-cd/current/amd64/iso-dvd/. I have also downloaded the MD5SUMS and MD5SUMS.sign .
I verified the md5sum of iso matches the entry present in MD5SUMS .
Now I want to verify MD5SUMS file against MD5SUMS.sign using GPG. I'm not very familiar with GPG. I tried verifying using
gpg --verify MD5SUMS.sign MD5SUMS, but i got the error
gpg: Can't check signature: public key not found.
That's expected because I haven't imported the public key accompanying the sign file. I couldn't find the required key to import and debian documentation also isn't clear about this.
Debian documentation about verifying cds with gpg includes a link to Debian GPG keyring and some Key Fingerprints as below.
pub 4096R/64E6EA7D 2009-10-03
Key fingerprint = 1046 0DAD 7616 5AD8 1FBC 0CE9 9880 21A9 64E6 EA7D
uid Debian CD signing key <[email protected]>
pub 4096R/6294BE9B 2011-01-05
Key fingerprint = DF9B 9C49 EAA9 2984 3258 9D76 DA87 E80D 6294 BE9B
uid Debian CD signing key <[email protected]>
sub 4096R/11CD9819 2011-01-05
pub 4096R/09EA8AC3 2014-04-15
Key fingerprint = F41D 3034 2F35 4669 5F65 C669 4246 8F40 09EA 8AC3
uid Debian Testing CDs Automatic Signing Key <[email protected]>
sub 4096R/6BD05CFB 2014-04-15
I don't know how to use the keyring or the key fingerprints. Please explain how can I verify the MD5SUMS file with MD5SUMS.sign file.
|
You missed the important line above:
gpg: Signature made Fri Sep 11 17:13:36 2015 CEST using RSA key ID 6294BE9B
gpg: Can't check signature: No public key
This tells you that this file is signed with key 6294BE9B. That is the key you need to receive first:
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 6294BE9B
Now you can verify that the file is indeed signed with that key. - If you trust that key everything is fine.
All keyservers are usually in sync with each other. It really doesn't matter which one you use. If you are unsure whether you got the correct key, either check that the fingerprint of that key (gpg --fingerprint 6294BE9B) is the same as given on the website, or check the signatures (gpg --list-sigs 6294BE9B) of that key. (If you trust the signers of the key, you can trust the key itself.)
| How to verify debian cds with gpg? |
1,320,296,561,000 |
The 'pass' password manager uses gpg keys.
http://www.passwordstore.org/
However, gpg itself can be used for symmetric encryption of files.
Does pass only work using public/private keys, or is it possible to use with symmetric encryption?
|
The pass password manager requires a public key for encrypting its files (where the managed passwords are stored) - and it requires a private key to decrypt its files.
It isn't possible to configure pass to use gpg's 'pure' symmetric file encryption (cf. the -c or --symmetric GPG options).
This is due to the design of pass - using GPG's public key cryptography for file encryption/decryption allows for flexibility, e.g. for configuring multiple keys - say - such that a group of users has access to the managed passwords.
Also note that GPG uses a hybrid scheme when encrypting a file for one or many recipients (i.e. using one or many public keys): it randomly generates a session key for the symmetric encryption of the file and then just uses the public key/keys to encrypt the session key.
| 'Pass' password manager - does it require public key? |
1,320,296,561,000 |
How do I distrust an Apt key in Debian Linux, or prevent one from being silently added via apt-key (like most commercial packages tend to do in their postinst scripts)?
If I run apt-key adv --edit-key ... trust, it doesn't seem to have any effect:
# apt-key adv --edit-key D38B4796 trust
Executing: /tmp/apt-key-gpghome.poumWAEgYJ/gpg.1.sh --edit-key D38B4796 trust
gpg (GnuPG) 2.1.18; Copyright (C) 2017 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.
pub rsa4096/7721F63BD38B4796
created: 2016-04-12 expires: never usage: SC
sub rsa4096/1397BC53640DB551
created: 2016-04-12 expires: 2019-04-12 usage: S
sub rsa4096/6494C6D6997C215E
created: 2017-01-24 expires: 2020-01-24 usage: S
[ unknown] (1). Google Inc. (Linux Packages Signing Authority) <[email protected]>
pub rsa4096/7721F63BD38B4796
created: 2016-04-12 expires: never usage: SC
sub rsa4096/1397BC53640DB551
created: 2016-04-12 expires: 2019-04-12 usage: S
sub rsa4096/6494C6D6997C215E
created: 2017-01-24 expires: 2020-01-24 usage: S
[ unknown] (1). Google Inc. (Linux Packages Signing Authority) <[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? 2
pub rsa4096/7721F63BD38B4796
created: 2016-04-12 expires: never usage: SC
sub rsa4096/1397BC53640DB551
created: 2016-04-12 expires: 2019-04-12 usage: S
sub rsa4096/6494C6D6997C215E
created: 2017-01-24 expires: 2020-01-24 usage: S
[ unknown] (1). Google Inc. (Linux Packages Signing Authority) <[email protected]>
Please note that the shown key validity is not necessarily correct
unless you restart the program.
gpg>
-- so when I re-run apt-key list, the trust level is still unknown:
# apt-key list D38B4796
pub rsa4096 2016-04-12 [SC]
EB4C 1BFD 4F04 2F6D DDCC EC91 7721 F63B D38B 4796
uid [ unknown] Google Inc. (Linux Packages Signing Authority) <[email protected]>
sub rsa4096 2016-04-12 [S] [expires: 2019-04-12]
sub rsa4096 2017-01-24 [S] [expires: 2020-01-24]
|
As far as I’m aware, the trust settings on keys don’t have any effect on apt. Trust in this context refers to the value given to signatures of other keys made with a given key; it’s about transitive trust in the web of trust, not trust in the validity of package signatures (or rather, repository signatures) made with a given key.
To “distrust” a repository key you need to delete it.
To prevent packages installing new keyrings, you can add a file to /etc/dpkg/dpkg.cfg.d/, called for example no-new-keyrings, containing
# Skip installation of new keyrings by default, but allow Debian keyrings
path-exclude=/etc/apt/trusted.gpg.d/*
path-include=/etc/apt/trusted.gpg.d/debian-archive-*
This won’t prevent packages installing keys using apt-key; to do that would probably involve writing a wrapper.
| How do I distrust an Apt key in Debian Linux? |
1,320,296,561,000 |
I am thinking if it is possible to autofetch public keys for new recipients from the main gpg/pgp key servers.
I was thinking about some setting in $HOME/.muttrc, studying here but did not find a conclusive setting for the target. I tried pgp_verify_sig there but my Mutt says source: errors in /home/users/leo/.muttrc, so implying me that it is not the correct parameter to autofetch public keys from the main key servers. Pseudocode
define main key servers if necessary
set autofetch of public keys for the senders from the key servers
Common view in my Mutt
[-- PGP output follows (current time: Wed 21 Jun 2017 10:52:06 AM EEST) --]
gpg: Signature made Wed 21 Jun 2017 10:51:18 AM EEST using RSA key ID ....
gpg: Can't check signature: public key not found
[-- End of PGP output --]
[-- The following data is signed --]
Testing SD Allen's proposal
Code in $HOME/.gnupg/gpg.conf
keyserver hkp://keys.gnupg.net
keyserver-options auto-key-retrieve
# Automatically verify the sign of a message when opened
set crypt_verify_sig=yes
Output: still same failed output PGP signature could NOT be verified in Mutt
OS: Debian 8.7
|
In order to do this, add this line to your ~/.gnupg/gpg.conf file:
keyserver <keyserver address>
keyserver-options auto-key-retrieve
| How to autofetch public keys in mutt? |
1,320,296,561,000 |
I'm using mutt, with notmuch-mutt indexing the mail. I have a macro defined in mutt to search multiple mailboxes, using notmuch's integration (as suggested in the man page).
macro index <F3> \
"<enter-command>set my_old_pipe_decode=\$pipe_decode my_old_wait_key=\$wait_key nopipe_decode nowait_key<enter>\
<shell-escape>notmuch-mutt -r --prompt search --decrypt<enter>\
<change-folder-readonly>`echo ${XDG_CACHE_HOME:-$HOME/.cache}/notmuch/mutt/results`<enter>\
<enter-command>set pipe_decode=\$my_old_pipe_decode wait_key=\$my_old_wait_key<enter>" \
"notmuch: search mail"
I also have GPG-encrypted email. mutt can unencrypt these fine, and its internal search works perfectly on the encrypted emails. However, notmuch-mutt fails to search these properly. Notmuch 0.6 (from 2011) apparently supports GPG, however this doesn't work for me out of the box. I'm running Notmuch 0.20.2. Is there a way to search encrypted mails using notmuch-mutt?
|
Update as of 2018/03/18: This feature was merged upstream, and released in notmuch 0.26.
Please note:
The contents of the index are sufficient to roughly
reconstruct the cleartext of the message itself, so please ensure
that the notmuch index itself is adequately protected. DO NOT USE
this feature without considering the security of your index.
See the comments below this answer how to make use of this feature.
--
This is in the works upstream, as of today, 2016/02/09. Quoting the linked mail:
This is the third draft of the series initially announced in
id:1449718786-28000-1-git-send-email-dkg at fifthhorseman.net (second
draft was in
id:1453258369-7366-1-git-send-email-dkg at fifthhorseman.net). It
differs from v2 in that it incorporates the recent improvements in
detecting and processing S/MIME signatures.
From the v2 description:
Notmuch currently doesn't index the cleartext of encrypted mail. This
is the right choice by default, because the index is basically
cleartext-equivalent, and we wouldn't want every indexed mailstore to
leak the contents of its encrypted mails.
However, if a notmuch user has their index in a protected location,
they may prefer the convenience of being able to search the contents
of (at least some of) their encrypted mail.
This series of patches enables notmuch to index the cleartext of
specific encrypted messages when they're being added via "notmuch new"
or "notmuch insert", via a new --try-decrypt flag.
If --try-decrypt is used, and decryption is successful for part of a
message, the message gets an additional "index-decrypted" tag. If
decryption of part of a message fails, the message gets an additional
"index-decryption-failed" tag.
v2 addresses the concerns raised from the helpful feedback on the
previous series, and adds a notmuch_indexopts_t object that can be
used to declare options for indexing messages, including a
"try_decrypt" boolean.
Additionally, this series adds a new function to libnotmuch:
notmuch_message_reindex (notmuch_message_t *message,
notmuch_indexopts_t *indexopts)
Which allows user of the library to adjust the indexing options of a
given message.
The CLI is additionally augmented with a new notmuch subcommand,
"notmuch reindex", which also has a --try-decrypt flag.
So a user who has their message index stored securely and wants to
index the cleartext of all encrypted messages they've received can do
something like:
notmuch reindex --try-decrypt tag:encrypted and not tag:index-decrypted
Or can clear all indexed cleartext from their database with:
notmuch reindex tag:encrypted and tag:index-decrypted
| How can I search gpg-encrypted email with notmuch-mutt? |
1,320,296,561,000 |
Whenever i save *.gpg files (symmetric password) using emacs the gcr-prompter displays dialog and asks me for password twice! It's so annoying, especially that my emacs remembers the password i type, and when i press escape twice on the dialog boxes, emacs saves the file properly. How can i disable the annoying dialogs? Maybe uninstall gcr-prompter completely?
I use Linux Mint 17 x64 with Cinamon desktop.
|
add this to .emacs:
;; Do not use gpg agent when runing in terminal
(defadvice epg--start (around advice-epg-disable-agent activate)
(let ((agent (getenv "GPG_AGENT_INFO")))
(setenv "GPG_AGENT_INFO" nil)
ad-do-it
(setenv "GPG_AGENT_INFO" agent)))
source: https://stackoverflow.com/a/16829842/3024945
| how to disable gcr-prompter dialogs? |
1,320,296,561,000 |
Is there any way to sign multiple files with GPG when the signing key is stored on a keycard? (Or more specifically in my case, a Yubikey).
Currently, I have a script where I loop over a number of files that I want to sign, e.g.:
for pkg in html/packages/*.tar;
do
gpg2 --detach-sign --armor -o $pkg.sig $pkg
done
This works, but as there is a pin-code on my keycard I'm being prompted to enter
my pin for each file which gets very tiresome after just a few files.
Is there any way to sign all files at once? Alternatively, is there some workaround for the signing process such that the pin-code can be cached between invocations?
|
If you can get the PIN into a variable your script can use, you can do something like:
for pkg in html/packages/*.tar;
do
echo ${PIN} | gpg --batch --yes --passphrase-fd 0 --detach-sign --armor -o $pkg.sig $pkg
done
From the man page:
--passphrase-fd n
Read the passphrase from file descriptor n. Only the first line will be read
from file descriptor n. If you use 0 for n, the passphrase will be read from
STDIN. This can only be used if only one passphrase is supplied.
Note that since Version 2.0 this passphrase is only used if the option --batch
has also been given. Since Version 2.1 the --pinentry-mode also needs to be set
to loopback.
For more details on the passphrase-fd (where gpg should expect to receive the passphrase from) option, https://stackoverflow.com/questions/19895122/how-to-use-gnupgs-passphrase-fd-argument is probably helpful
| GPG: Generating signatures for multiple files |
1,320,296,561,000 |
I use pass as a password manager. I would
like my passphrase to be cached during a certain amount of time to avoid
retyping my passphrase every time that I want to clip one of my passwords.
Pass is using gpg-agent to decrypt
passwords.
According to the man page and a previously answered question, the solution is to set up the following options in ~/.gnupg/gpg-agent.conf:
default-cache-ttl 3600
max-cache-ttl 86400
Unfortunately, it does not work on my machine, I am asked for my passphrase each time I ask for a password.
I have verified that my gpg-agent.conf is read by adding and removing the
no-grab option. This works fine.
I am on a Debian machine with i3wm desktop. So I do not use gnome-keyring manager.
|
I solved the problem by upgrading gnupg from 1.4 to 2.1 which seemed to simplify a lot the configuration.
However, it generated an error of migration of the secret key between gpg and
gpg2.
gpg2 generated the following error message when I was requiring password from
pass:
gpg: decryption failed: No secret key
The solution came from this previous issue:
gpg --export [ID] > public.key
gpg --export-secret-keys [ID] > private.key
gpg2 --import public.key
gpg2 --import private.key
rm public.key private.key
with [ID] being the id of my key. It imports correctly the keys from gpg to gpg2.
Finally I rebooted and now my passphrase is cached, which makes me a really happy user of pass.
| How to make the default-cache-ttl option of gpg-agent work? |
1,320,296,561,000 |
I just installed Centos 6.7 on Virtualbox and ran yum update with this output:
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid : CentOS-6 Key (CentOS 6 Official Signing Key) <[email protected]>
Package: centos-release-6-7.el6.centos.12.3.x86_64 (@anaconda-CentOS-201508042137.x86_64/6.7)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]:
Didn't install any keys
What is the problem?
|
This update is for installing repository keys, hence asking for confirmation as installing wrong keys has security implications.
The error message is because the default is not installing as the capital N shows. As you have pressed ENTER, it displayed the error.
Please run yum update again and press Y when presented with this message.
| yum update exits with "Didn't install any keys" |
1,320,296,561,000 |
I have a desktop Linux system which I regularly create clones of to a local RAID-6 array using Clonezilla.
It's proven to be quite a hassle to walk through the backup process, which takes quite a few steps:
Select Dvorak as the Keyboard Layout
Mount the RAID-6 array.
Select to backup the entire array and to check it.
Select compression options.
Confirm that everything is good and to proceed with the backup.
I'd like to configure a distribution that does all of this without any user input at boot.
How can I create a distribution for a thumb stick which automatically does all of this for me at boot without any prompts, then encrypts all of the backup files using GPG, then shuts down?
|
This guide from the Clonezilla website shows you how to do unattended runs.
excerpt
By modifying the boot parameters in syslinux/syslinux.cfg (for live USB) or isolinux/isolinux.cfg (for CD), you can preseed most of the options so that Clonezilla live can do the job for you with less interactive steps, or it's possible to make it run in an unattended mode.
See this URL for the fully detailed steps.
In this example: Preseed some options to do restoring job after booting
| Automated Clonezilla backup and GPG encryption |
1,320,296,561,000 |
I'm having trouble using gpg (actually, the gpg-agent) on my Debian Bullseye (Stable) system. More precisely, I use the following:
gpg --version | head -n2
gpg (GnuPG) 2.2.27
libgcrypt 1.8.8
uname -v
#1 SMP Debian 5.10.46-4 (2021-08-03)
lsb_release -a 2> /dev/null
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
I haven't rebooted my machine for approx 3 months. During that time I was able to use gpg without difficulties (encrypting, decrypting, signing, verifying, key management). I made multiple updates during the last months, none of which created any problems for me (in addition I'm using needrestart). I didn't change anything in the relevant config files (I know of, being ~/.gnupg/gpg.conf, ~/.gnupg/gpg-agent.conf, ~/.gnupg/dirmngr.conf) in the last 3 months.
Today I restarted my machine and suddenly I wasn't able to use my gpg-agent for anything, where secret keys are involved. While gpg -k [1] and gpg --search-keys DEADBEEF lead to results, gpg -K as well as gpg -d /PATH/TO/ENCRYPTED/FILE hangs indefinitely. Similarly, gpg-connect-agent reloadagent /bye and gpgconf --kill gpg-agent as well as systemctl --user start gpg-agent leads to hanging. Similarly, my systemd-unit-file is not out of the ordenary:
systemctl --user cat gpg-agent | grep -Ev '^#|^$'
[Unit]
Description = gpg-agent (password store for gpg-keys)
[Service]
Type = forking
ExecStart = /usr/bin/gpg-agent --daemon
ExecStop = /usr/bin/gpg-connect-agent /bye
Restart = on-abort
[Install]
WantedBy = default.target
I'm aware that this problem has already been described by others (see e.g. here but the mentioned solution (pkill -9 gpg-agent) does not apply to me, since this is happening eventhough no other process containing the string gpg (read: the gpg-agent) is running.
ps -ef | grep gpg && echo " " && gpg --verbose --debug-level guru -K
MYUSERNAME 59248 59247 0 17:17 pts/1 00:00:00 grep --color=auto gpg
gpg: enabled debug flags: packet mpi crypto filter iobuf memory cache memstat trust hashing ipc clock lookup extprog
gpg: DBG: [not enabled in the source] start
gpg: DBG: [not enabled in the source] keydb_new
gpg: DBG: [not enabled in the source] keydb_search_reset
gpg: DBG: keydb_search: reset (hd=0x000055c04a474cd0)
gpg: DBG: [not enabled in the source] keydb_search enter
gpg: DBG: keydb_search: 1 search descriptions:
gpg: DBG: keydb_search 0: FIRST
gpg: DBG: keydb_search: searching keybox (resource 0 of 1)
gpg: DBG: keydb_search: searched keybox (resource 0 of 1) => Success
gpg: DBG: [not enabled in the source] keydb_search leave (found)
gpg: DBG: [not enabled in the source] keydb_get_keybock enter
gpg: DBG: parse_packet(iob=1): type=6 length=51 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=12 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=13 length=19 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=12 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=2 length=150 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=6 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=2 length=150 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=6 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=14 length=56 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=2 length=126 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=6 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=14 length=51 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=2 length=245 (parse.../../g10/keydb.c.1242)
gpg: DBG: parse_packet(iob=1): type=12 length=6 (parse.../../g10/keydb.c.1242)
gpg: DBG: iobuf-1.0: underflow: buffer size: 924; still buffered: 0 => space for 924 bytes
gpg: DBG: iobuf-1.0: close '?'
<<< HERE HANGING INDEFINITELY >>>
^C
gpg: signal Interrupt caught ... exiting
Also my variables GPG_AGENT_INFO and GPG_TTY are set.
echo -e "$GPG_AGENT_INFO\n$GPG_TTY"
/run/user/1000/gnupg/S.gpg-agent:0:1
/dev/pts/1
Rebooting btw. didn't change anything. Any ideas?
edit1: reinstalling gpg, gpg-agent and dirmngr doesn't fix the issue. Additionally, removing the files ~/.gnupg/gpg.conf, ~/.gnupg/gpg-agent.conf and ~/.gnupg/dirmngr.conf doesn't solve it.
edit2: in the meantime I upgraded from PureOS Amber to Debian Stable (Bullseye) and reinstalled a new version of gpg, gpg-agent, dirmngr and libgcrypt20 (and changed the text above to reflect the new version), but the problem is still present.
[1] technically speaking gpg -k also hung, but I assume this was because I enabeled the option with-secret in my gpg.conf-file. After commenting that out this problem disappeared.
|
I finally found a solution, although I'm not sure I understand it.
Somehow the version of gpg-agent started by systemd was the issue. When performing systemctl --user mask gpg-agent and then restarting the gpg-agent manually, the problem disappeared. I'll try to understand why that was the case and then write an update here.
| gpg-agent hanging when trying to access private keys |
1,320,296,561,000 |
The GNU Privacy Handbook says:
The command-line option --sign is used to make a digital signature.
The document to sign is input, and the signed document is output.
alice% gpg --output doc.sig --sign doc
You need a passphrase to unlock the private key for
user: "Alice (Judge) <[email protected]>"
1024-bit DSA key, ID BB7576AC, created 1999-06-04
Enter passphrase:
Why doesn't it ask which private key to be used? Can't the user running the command hold multiple private keys?
A document can be encrypted with a symmetric cipher by using the
--symmetric option.
alice% gpg --output doc.gpg --symmetric doc
Enter passphrase:
Does gpg use the passphrase to symmetrically encrypt the input file?
Or does it use the passphrase just to access the key which will be used to symmetrically encrypt the input file?
If latter, why does it not ask which key to be used for symmetric encryption? Can't the user hold multiple keys which can be used for symmetric encryption?
When decrypt a symmetrically encrypted file,
alice% gpg --descrypt doc.gpg
will succeed. why does it not ask for passphrase (and the key to decrypt)? How can others then decrypt doc.gpg after I give it to them?
Thanks.
|
GnuPG will use the first key found in the secret keyring if neither --default-user nor --local-user is specified. You may also define the default key to be used with
default-key KEYID
in ~/.gnupg/gpg.conf.
Symmetric encryption does not involve any public or private keys. The passphrase that you enter is used to both encrypt and decrypt the message (hence "symmetric").
In your example, you will not be asked for the passphrase when decrypting because the gpg-agent process has cached the passphrase that you used when encrypting the message. If you terminated the agent and tried to decrypt the message again, you would be asked for the passphrase.
If you share your doc.gpg file and if it's encrypted with symmetric encryption, you would also need to share the passphrase somehow for enabling the recipients to decrypt the message. Anyone with the passphrase would be able to decrypt the message.
When using key encryption with signing, it would be enough to share you public key (for verification of the signature). Without signing, you don't have to share your key. Using key encryption, the message would be encrypted for one or several specific recipients, so you would need to have their public keys to perform the encryption. Without access to the private keys of the specific recipients, the message would not be able to be decrypted.
| Why doesn't gpg need us to specify which keys for encryption and decryption? |
1,320,296,561,000 |
I try to upgrade jenkins.
I use the new way to use gpg keys:
wget https://pkg.jenkins.io/debian-stable/jenkins.io.key
gpg --dearmor jenkins.io.key
mv jenkins.io.key.gpg /usr/share/keyrings/jenkins-keyring.asc
cat /etc/apt/sources.list.d/jenkins.list
deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/
apt-key:
apt-key list | grep -i jenkins # nothing
# file /usr/share/keyrings/jenkins-keyring.asc
/usr/share/keyrings/jenkins-keyring.asc: PGP/GPG key public ring (v4) created Mon Mar 30 15:10:17 2020 RSA (Encrypt or Sign) 4096 bits MPI=0x99a14538d6e6150d...
But when I run apt update:
W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://pkg.jenkins.io/debian-stable binary/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY FCEF32E745F2C3D5
W: Failed to fetch https://pkg.jenkins.io/debian-stable/binary/Release.gpg The following signatures couldn't be verified because the public key is not available: NO_PUBKEY FCEF32E745F2C3D5
W: Some index files failed to download. They have been ignored, or old ones used instead.
What's wrong?
|
Repository signing keys were changed.
Beginning March 28, 2023, the Jenkins weekly releases will use new repository signing keys for the Linux installation packages. The same change will be made in Jenkins LTS releases beginning April 5, 2023. Administrators of Linux systems must install the new signing keys on their Linux servers before installing Jenkins Jenkins weekly 2.397 or Jenkins LTS 2.387.2.
https://www.jenkins.io/blog/2023/03/27/repository-signing-keys-changing/
Install the new signing keys, and wait for updating repository signed by new key until 5 April.
| Can't upgrade Jenkins on Debian11, the public key is not available: NO_PUBKEY FCEF32E745F2C3D5 |
1,320,296,561,000 |
I just started using pass of by Jason A. Donenfeld as a password manager.
I entered a password (e.g. email/[email protected]). To retrieve it I type
pass email/[email protected]
I'm being asked the master password. But then if I type again pass email/[email protected], the master password is not being asked and the password for email/[email protected] is output in the terminal.
For security reasons, I want to be asked the master password each time I retrieve a password. How can I do it?
|
pass uses GnuPG to handle encryption.
Recent releases of GnuPG uses a GPG daemon.
This GPG daemon caches your valid authentication for 600 seconds (default-cache-ttl), which may be refreshed to another 600 seconds if you use GnuPG again within that time, up to a maximum of two hours (max-cache-ttl).
You have two options:
Kill the GPG agent process after each use of pass. You do this with
gpgconf --kill gpg-agent
Configure the "cache max time to live" for the GPG agent (the maximum time a valid authentication is remembered, by default two hours).
This number may be changed by changing the GPG daemon's configuration file.
You do this by adding the following line to your ~/.gnupg/gpg-agent.conf file (you may have to create this file):
max-cache-ttl 0
If a GPG agent is currently running, then make sure to terminate it with the gpgconf command as shown above to ensure that the agent reads the updated configuration file when it is started.
See also the gpg-agent manual, specifically the documentation for the --max-cache-ttl option (which corresponds to the max-cache-ttl configuration setting). The manual also mentions the gpgpconf --kill gpg-agent command.
| Re-ask master password in pass each time |
1,320,296,561,000 |
I generated a PGP key with GnuPG over a year ago. Since I haven't had to really touch it since, I'm extremely foggy on the ins and outs of GPG (though I understand asymmetric key encryption in principle). I had used this key to authenticate SSH logins, right up until accidentally deleted it yesterday. So, today, I set out to generate it again.
I run gpg --export-secret-key -a "Ryan Lue" > ~/.ssh/id_rsa, and it prompts me for a password. I enter the password, and out comes the id_rsa file. Now, when I try to SSH into my servers, it throws the following warning:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for 'id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
So, I obediently chmod 600 ~/.ssh/id_rsa. Then, I try again, and it prompts for a password (actually, since I'm on a Mac, Keychain prompts me for a password). I enter the same password I used to export it, and each time, it fails, spitting out the following error on the command line:
Saving password to keychain failed
I've also tried adding the key using ssh-agent, and that actually prompts me for the password on the command line:
Enter passphrase for /Users/rlue/.ssh/id_rsa:
Either way, it keeps rejecting the password. I'm 100% sure I'm entering the same passphrase at these prompts as I do to export it: I've successfully exported the key about a dozen times and failed to authenticate it in use about four dozen times.
What am I missing?
|
OpenPGP (as implemented by GnuPG) and SSH do not share a common key format, although they rely on the same cryptographic principles.
GnuPG implements the ssh-agent protocol, though, so you can still use your OpenPGP keys through GnuPG for SSHing into other computers.
enable the ssh-agent protocol by adding enable-ssh-support to ~/.gnupg/gpg-agent.conf
export SSH_AUTH_SOCK=$HOME/.gnupg/S.gpg-agent.ssh; you might want to do that in your ~/.profile
kill ssh-agent if started and reload gpg-agent (gpg-connect-agent reloadagent /bye)
export and add your public key to target servers (ssh-add -L should now contain the familiar SSH public key line for your OpenPGP key)
ssh to the target server as with a normal SSH key
This also works great with OpenPGP smartcards or USB dongles, I'm using this to protect my SSH key with a YubiKey.
| Can't use OpenPGP key exported from GnuPG with SSH |
1,320,296,561,000 |
I am trying to decrypt a file in a script with gpg batch mode, but command is not executed because the passphrase contains a "!"
echo "m!pass"|gpg --batch --passphrase-fd 0 --decrypt-file plain.gpg
bash: !pass": event not found
or
gpg --batch --passphrase "m!pass" -d plain.gpg
bash: !pass": event not found
I guess bash is interpreting the exclamation mark as a reference to the command execution history.
Which would be the right way to do it in GPG batch mode?
|
Use single quotes instead of double:
$ echo "m!pass"
bash: !pass": event not found
$ echo 'm!pass'
m!pass
This is quite nicely explained in the bash manual (emphasis added):
Single Quotes
Enclosing characters in single quotes (‘'’) preserves the literal
value of each character within the quotes. A single quote may not
occur between single quotes, even when preceded by a backslash.
Double Quotes
Enclosing characters in double quotes (‘"’) preserves the literal
value of all characters within the quotes, with the exception of ‘$’,
‘’, ‘\’, and, when history expansion is enabled, ‘!’. The characters
‘$’ and ‘’ retain their special meaning within double quotes (see
Shell Expansions). The backslash retains its special meaning only when
followed by one of the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or
newline. Within double quotes, backslashes that are followed by one of
these characters are removed. Backslashes preceding characters without
a special meaning are left unmodified. A double quote may be quoted
within double quotes by preceding it with a backslash. If enabled,
history expansion will be performed unless an ‘!’ appearing in double
quotes is escaped using a backslash. The backslash preceding the ‘!’
is not removed.
| Decrypt file using gpg in batch mode when passphrase includes a "!"? |
1,320,296,561,000 |
We can sign a file with gpgp:
gpg -s file.pdf
Which generates a file signature file.pdf.gpg.
It is also possible to make a detached signature:
gpg -b file.pdf
Which generates file.pdf.sig.
I noticed that the *.sig files are always 566 bytes, while the size of *.gpg is proportional to the size of the original file.
My questions are:
What is the difference between a GPG signature and a detached signature?
Why are *.gpg signatures larger?
Is one more secure than the other?
|
What is the difference between a GPG signature and a detached signature?
By "GPG signature" you mean a signed message. This is the data being signed and the signature combined into one file. In contrast, a detached signature is separate from the file being signed.
Why are *.gpg signatures larger?
Because it includes a compressed copy of the file that is being signed along with the signature data, whereas a detached signature is the signature data only.
Is one more secure than the other?
The signatures are calculated in the exact same way for both formats.
For anything other than small text files it is usually easier to use a detached signature.
| What is the difference between a GPG signature and a detached signature? |
1,320,296,561,000 |
I encrypted a file with my own gpg key.
After reboot, I can view the decrypted content of the gpg file directly with less, but cat/gvim/gedit show binary content.
Why does less have this function? Does it automatic decrypt with gnome-keying?
▶ file pw.gpg
pw.gpg: PGP RSA encrypted session key ....
|
less can use a helper program to decode files for display. This is configured using the LESSOPEN environment variable; see
echo $LESSOPEN
Typically this uses a helper called lesspipe.
See the “input preprocessor” section of the less manpage for details.
In your case, the helper uses gpg to decrypt the file, and gpg gets your key from the agent (the keyring).
| Why can I decrypt a gpg-encrypted file with less? |
1,320,296,561,000 |
Having a hard time figuring out the debugging steps for this behavior.
I'll run some gpg command and, typically, about 20 seconds later a GUI Pinentry window will pop up where I type in my password and the command proceeds.
Occasionally though, the prompt instantaneously appears in my terminal (without me changing any config). On other rare occasions, the GUI Pinentry will be instant.
One time I noticed the GUI Pinentry was instant was when I was running on a single monitor. I typically have an external monitor connected to my laptop over HDMI.
Another time I noticed I was getting prompted in my terminal was when my window manager had crashed, I killed the Xorg server process from a seperate TTY, then re-started my window manager.
I'm running Manjaro Linux with StumpWM as the window manager. I'm not sure what other pieces of software or config are relevant to this.
|
TLDR: I needed to pass the --daemonize flag to gnome-keyring-daemon.
I had /usr/bin/gnome-keyring-daemon --start --components=gpg,pkcs11,secrets,ssh in my .xinitrc.
Adding the --daemonize argument appears to have resolved this.
/usr/bin/gnome-keyring-daemon --daemonize --start --components=gpg,pkcs11,secrets,ssh
Below is a hodge-podge of troubleshooting steps I took to resolve this in case you're experiencing a similar problem but not quite exactly the same.
I started with a bag of keywords that I figured were relevant: gpg, keyring, gpg-agent, pinentry, gpg password prompt.
Search the output of journalctl -xe for relevant-looking information. In this case, I saw:
Failed to lookup password for key <...> with secret service: Error
calling StartServiceByName for org.freedesktop.secrets...>
That gave me another keyword to search for: org.freedesktop.secrets. Looking in journalctl output for that led me to another entry:
dbus-daemon[2210]: [session uid=1000 pid=2208] Failed to activate service 'org.freedesktop.secrets': timed out (service_start_timeout=120000ms)
That gave me another keyword... dbus-daemon.
I used dbus-monitor to see what was being sent over DBus and read any error output.
I also sent a message to DBus to see if org.freedesktop.secrets was running. (https://rtfm.co.ua/en/what-is-linux-keyring-gnome-keyring-secret-service-and-d-bus/)
dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames
...
string "org.freedesktop.secrets"
...
Everything pointed to the org.freedesktop.secrets service not running.
How are gpg-agent, org.freedesktop.secrets, and dbus-daemon connected?
gpg-agent talks to a "keyring" over "DBus". In my case, my keyring was gnome-keyring-daemon.
| Why would GPG Pinentry be slow when opening in GUI but instantaneous when opening in CLI? |
1,599,711,376,000 |
I know there is a gpg-agent config to set how long we can cache a password into gpg-agent. The setting is called --max-cache-ttl n
But when a passphrase is cached in gpg-agent for example for 10 seconds, how do I obtain the current cache duration like how many seconds left until it will be expired? Is there a query option for this where I can obtain directly from gpg-agent?
|
Not sure about the built-in feature that gpg-agent has. I don't think it is possible but I'm showing a trick how you can get cache duration left:
First rule: When you cache a passphrase in gpg-agent, you first store the date in unix timestamp as a variable inside a config file:
GPG_MY_CONFIG="~/.gnupg/my-gpg.conf"
function set_config() {
sudo sed -i "s/^\($1\s*=\s*\).*\$/\1$2/" $GPG_MY_CONFIG
}
echo "date_cached=$(date +%s)" | sudo tee --append $GPG_MY_CONFIG
# Now you got the following date (with unix timestamp) inside my-gpg.conf like below:
# date_cached=1599710839
# When you cached a new password, then run this code to update new date in unix timestamp:
# set_config date_cached "$(date +%s)"
It's best to have the current --max-cache-ttl n value from gpg-agent.conf file, so we can query this:
# ~/.gnupg/gpg-agent.conf
allow-preset-passphrase
default-cache-ttl 10
max-cache-ttl 10
First, read the setting max-cache-ttl value and save it in a variable expired_in_second like this:
# location of gpg config file
GPG_CONFIG_FILE="~/.gnupg/gpg-agent.conf"
# read the config file for value max-cache-ttl
expired_in_second=$(grep -oP 'max-cache-ttl\s*\K\d+' $GPG_CONFIG_FILE)
So now you got 2 important variables, you can get expired date by using this 2 variables:
# First source the config file:
source $GPG_MY_CONFIG
# expired_date = date_cached_previously + expired_duration (from max-cache-ttl)
expired_date=$(date -d "(date -d @${date_cached}) + $expired_in_second seconds")
and to get the duration left you can use this (compare the expired date with the current time):
# second_left = expired_date - current_date
second_left="$(( $(date -d "$expired_date" "+%s") - $(date +%s) ))"
echo "$second_left seconds remaining before password is going to be expired"
Output:
10 seconds remaining before password is going to be expired
I believe the above code can be simplified more. Hope this help :)
| How to get passphrase cache duration left in gpg-agent? |
1,599,711,376,000 |
There are many packages on AUR which, when you attempt to install them, result in an error like: ==> ERROR: One or more PGP signatures could not be verified!
This is resolved by importing the key with something like gpg --recv-keys 123456789ABCDEF. The AUR discussion will often provide the key.
I have a few questions about this:
What exactly do these keys do? What is being verified with GPG, and why is it necessary?
Why is it necessary to import keys by hand? Why can't it be automated?
If blindly importing the key from the AUR comment thread is bad, what steps am I supposed to take to "verify" the key?
Where am I supposed to find the key if nobody's bothered to post it in the comments, and if I don't have time to post a comment and hope the maintainer replies?
Searching online, I've found references to a well known blog post. I'm sad to say that after several careful readings I still do not understand the above points.
|
What exactly do these keys do? What is being verified with GPG, and why is it necessary?
The keys are used to verify that the software you're downloading is what the author of the package intended it to be instead of trojan-horse malware from a repository server that may have been successfully infiltrated by an attacker. Or maybe an attacker can redirect your download request to his disguised malware repository instead of a genuine AUR repository. Verification by GPG makes it very difficult for an attacker to successfully use the software repositories as a malware distribution channel.
Why is it necessary to import keys by hand? Why can't it be automated?
You're supposed to make a conscious choice on whether you trust a particular software author/packager or not, and whether you're confident enough for your purposes that the key you've received is genuine and not from an imposter.
The necessary trust & confidence level depends on what you're doing: a private home system for fun, a server that will handle other people's health and/or credit card information for a business, and an ancillary support server for a national missile defense system should each have somewhat different requirements.
If blindly importing the key from the AUR comment thread is bad, what steps am I supposed to take to "verify" the key?
If the key is signed by other people whose keys you already have and you trust those people's judgement at least when it comes to signing GPG keys, you can take that as evidence that the key is probably genuine. Otherwise, you might try getting the key from multiple different sources and compare the results. If it's important enough for you, you might even call or meet the developer to get stronger confirmation that you have the right key.
Where am I supposed to find the key if nobody's bothered to post it in the comments, and if I don't have time to post a comment and hope the maintainer replies?
GPG public keys that are intended to be widely used are commonly published on SKS keyservers: if you don't have the right key, the package tools should be able to display the keyID of the required key, and you can use that to search for the key on the keyservers.
See here for more information on SKS keyserver network: https://sks-keyservers.net/
You can also google for the keyID.
| Why is it sometimes necessary to manually import keys? |
1,599,711,376,000 |
I've performed the following test on a docker alpine linux:
ole@MKI:~$ docker run --rm -it alpine /bin/ash
/ # apk add --update duplicity
fetch http://dl-4.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-4.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/28) Installing libbz2 (1.0.6-r4)
(2/28) Installing expat (2.1.0-r2)
...
(28/28) Installing duplicity (0.7.05-r0)
Executing busybox-1.24.1-r7.trigger
OK: 72 MiB in 39 packages
/ # gpg --list-keys
gpg: directory '/root/.gnupg' created
gpg: new configuration file '/root/.gnupg/dirmngr.conf' created
gpg: new configuration file '/root/.gnupg/gpg.conf' created
gpg: WARNING: options in '/root/.gnupg' are not yet active during this run
gpg: keybox '/root/.gnupg/pubring.kbx' created
gpg: /root/.gnupg/trustdb.gpg: trustdb created
/ # gpg --list-keys
/ # gpg --gen-key
gpg (GnuPG) 2.1.10; Copyright (C) 2015 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.
Note: Use "gpg2 --full-gen-key" for a full featured key generation dialog.
GnuPG needs to construct a user ID to identify your key.
Real name: Testing
Email address: testing@test
You selected this USER-ID:
"Testing <testing@test>"
Change (N)ame, (E)mail, or (O)kay/(Q)uit? O
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.
gpg: agent_genkey failed: No such file or directory
Key generation failed: No such file or directory
/ # ls /root/.gnupg/
S.gpg-agent dirmngr.conf gpg.conf private-keys-v1.d pubring.kbx trustdb.gpg
/ #
Any idea as to why the key generation is failing?
[Edit]
I could always just generate the keys using an ubuntu image and mount them in a volume. That's ultimately what I'm doing anyways, but I thought it would nice to have this working with the alpine image so I pasted the strace below as suggested:
/ # strace -f gpg --gen-key
execve("/usr/bin/gpg", ["gpg", "--gen-key"], [/* 6 vars */]) = 0
arch_prctl(ARCH_SET_FS, 0x7f75271edda8) = 0
set_tid_address(0x7f75271edde0) = 17
open("/etc/ld-musl-x86_64.path", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/lib/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=87976, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0!\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2187264, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f7526d4f000
mmap(0x7f7526f63000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x14000) = 0x7f7526f63000
close(3) = 0
open("/lib/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=856824, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\214\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2957312, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f7526a7d000
mmap(0x7f7526d45000, 40960, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xc8000) = 0x7f7526d45000
mmap(0x7f7526d4e000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f7526d4e000
close(3) = 0
open("/lib/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=67520, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0p'\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2166784, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f752686c000
mmap(0x7f7526a7b000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xf000) = 0x7f7526a7b000
close(3) = 0
open("/lib/libassuan.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/local/lib/libassuan.so.0", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/lib/libassuan.so.0", O_RDONLY|O_CLOEXEC) = 3
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
fstat(3, {st_mode=S_IFREG|0755, st_size=67616, ...}) = 0
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\2204\0\0\0\0\0\0"..., 960) = 960
mmap(NULL, 2166784, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x7f752665b000
mmap(0x7f752686a000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0xf000) = 0x7f752686a000
close(3) = 0
mprotect(0x7f7526f63000, 4096, PROT_READ) = 0
mprotect(0x7f7526d45000, 4096, PROT_READ) = 0
mprotect(0x7f7526a7b000, 4096, PROT_READ) = 0
mprotect(0x7f752686a000, 4096, PROT_READ) = 0
mprotect(0x7f75271ec000, 4096, PROT_READ) = 0
mprotect(0x7f752749a000, 8192, PROT_READ) = 0
fstat(0, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 24), ...}) = 0
fstat(1, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 24), ...}) = 0
fstat(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 24), ...}) = 0
access("/etc/gcrypt/fips_enabled", F_OK) = -1 ENOENT (No such file or directory)
open("/proc/sys/crypto/fips_enabled", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/gcrypt/hwf.deny", O_RDONLY) = -1 ENOENT (No such file or directory)
prlimit64(0, RLIMIT_CORE, NULL, {rlim_cur=0, rlim_max=RLIM64_INFINITY}) = 0
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_BLOCK, ~[], NULL, 8) = 0
prlimit64(0, RLIMIT_CORE, {rlim_cur=0, rlim_max=RLIM64_INFINITY}, NULL) = 0
futex(0x7f75271f011c, FUTEX_WAKE_PRIVATE, 2147483647) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGINT, {0x7f752726a170, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGHUP, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGHUP, {0x7f752726a170, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGTERM, {0x7f752726a170, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {0x7f752726a170, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGSEGV, NULL, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGSEGV, {0x7f752726a170, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGUSR1, {0x7f752726a0d4, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
rt_sigaction(SIGPIPE, {SIG_IGN, [], SA_RESTORER, 0x7f7526fad1c2}, NULL, 8) = 0
mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f7527492000
getuid() = 0
mlock(0x7f7527492000, 32768) = 0
access("/root/.gnupg/gpg.conf-2.1.10", R_OK) = -1 ENOENT (No such file or directory)
access("/root/.gnupg/gpg.conf-2.1", R_OK) = -1 ENOENT (No such file or directory)
access("/root/.gnupg/gpg.conf-2", R_OK) = -1 ENOENT (No such file or directory)
access("/root/.gnupg/gpg.conf", R_OK) = -1 ENOENT (No such file or directory)
access("/root/.gnupg/options", R_OK) = -1 ENOENT (No such file or directory)
stat("~/.gnupg", 0x7fff3556cc38) = -1 ENOENT (No such file or directory)
stat("/root/.gnupg/gpg.conf", 0x7fff3556cc38) = -1 ENOENT (No such file or directory)
open("/root/.gnupg/gpg.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
writev(2, [{"", 0}, {"gpg (GnuPG) 2.1.10; Copyright (C"..., 69}], 2gpg (GnuPG) 2.1.10; Copyright (C) 2015 Free Software Foundation, Inc.) = 69
writev(2, [{"", 0}, {"\n", 1}], 2
) = 1
writev(2, [{"", 0}, {"This is free software: you are f"..., 121}], 2This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
) = 121
writev(2, [{"", 0}, {"\n", 1}], 2
) = 1
access("/root/.gnupg/random_seed", F_OK) = -1 ENOENT (No such file or directory)
open("/root/.gnupg/pubring.gpg", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/root/.gnupg/pubring.kbx", O_RDONLY) = -1 ENOENT (No such file or directory)
access("/root/.gnupg/pubring.kbx", F_OK) = -1 ENOENT (No such file or directory)
access("/root/.gnupg", F_OK) = -1 ENOENT (No such file or directory)
mkdir("/root/.gnupg", 0700) = 0
write(2, "gpg: directory '/root/.gnupg", 28gpg: directory '/root/.gnupg) = 28
write(2, "' created\n", 10' created
) = 10
open("/usr/share/gnupg/dirmngr-conf.skel", O_RDONLY) = 3
umask(077) = 022
open("/root/.gnupg/dirmngr.conf", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
ioctl(4, TIOCGWINSZ, 0x7fff3556c908) = -1 ENOTTY (Not a tty)
umask(022) = 077
readv(3, [{"", 0}, {"# dirmngr-conf.skel - Skeleton t"..., 1024}], 2) = 1024
readv(3, [{"", 0}, {"nd receive keys to and from a ke"..., 1024}], 2) = 1024
writev(4, [{"# dirmngr.conf - Options for Dir"..., 1024}, {"L", 1}], 2) = 1025
readv(3, [{"", 0}, {" and only one is a Tor hidden\n# "..., 1024}], 2) = 704
writev(4, [{"DAP\n# support).\n#\n# Example HKP "..., 1024}, {"c", 1}], 2) = 1025
readv(3, [{"", 0}, {" and only one is a Tor hidden\n# "..., 1024}], 2) = 0
writev(4, [{"ally running or not (on a per se"..., 593}, {NULL, 0}], 2) = 593
close(4) = 0
close(3) = 0
write(2, "gpg: new configuration file '/ro"..., 54gpg: new configuration file '/root/.gnupg/dirmngr.conf) = 54
write(2, "' created\n", 10' created
) = 10
open("/usr/share/gnupg/gpg-conf.skel", O_RDONLY) = 3
umask(077) = 022
open("/root/.gnupg/gpg.conf", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
ioctl(4, TIOCGWINSZ, 0x7fff3556c908) = -1 ENOTTY (Not a tty)
umask(022) = 077
readv(3, [{"", 0}, {"# These first three lines are no"..., 1024}], 2) = 1024
readv(3, [{"", 0}, {"\n\n# Uncomment the following opti"..., 1024}], 2) = 1024
writev(4, [{"# Options for GnuPG\n# Copyright "..., 1024}, {"o", 1}], 2) = 1025
readv(3, [{"", 0}, {"nce you may want to use this opt"..., 1024}], 2) = 1024
writev(4, [{"re than 1 secret key in your key"..., 1024}, {" ", 1}], 2) = 1025
readv(3, [{"", 0}, {"\n# \"0x12345678\". Note there is "..., 1024}], 2) = 1024
writev(4, [{"subkey, ensure that the cross\n# "..., 1024}, {"o", 1}], 2) = 1025
readv(3, [{"", 0}, {"r.\n#\n# verbose = show more infor"..., 1024}], 2) = 1024
writev(4, [{" another group. Note also that\n"..., 1024}, {"t", 1}], 2) = 1025
readv(3, [{"", 0}, {"ys to the keyserver.\n\n#keyserver"..., 1024}], 2) = 1024
writev(4, [{"o increase the amount\n# "..., 1024}, {"I", 1}], 2) = 1025
readv(3, [{"", 0}, {"c OS X and Windows, the default "..., 1024}], 2) = 413
writev(4, [{"Ds in key listings and\n# when a "..., 1024}, {"t", 1}], 2) = 1025
readv(3, [{"", 0}, {"c OS X and Windows, the default "..., 1024}], 2) = 0
writev(4, [{"o-viewer \"qiv %i\"\n# photo-viewer"..., 307}, {NULL, 0}], 2) = 307
close(4) = 0
close(3) = 0
write(2, "gpg: new configuration file '/ro"..., 50gpg: new configuration file '/root/.gnupg/gpg.conf) = 50
write(2, "' created\n", 10' created
) = 10
write(2, "gpg: WARNING: options in '/root/"..., 38gpg: WARNING: options in '/root/.gnupg) = 38
write(2, "' are not yet active during this"..., 37' are not yet active during this run
) = 37
access("/root/.gnupg", F_OK) = 0
getpid() = 17
uname({sysname="Linux", nodename="60fbb80a7ebb", ...}) = 0
getpid() = 17
open("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", O_WRONLY|O_CREAT|O_EXCL, 0644) = 3
write(3, " 17\n", 11) = 11
write(3, "60fbb80a7ebb", 12) = 12
write(3, "\n", 1) = 1
close(3) = 0
stat("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", {st_mode=S_IFREG|0644, st_size=24, ...}) = 0
link("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", "/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17x") = 0
stat("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", {st_mode=S_IFREG|0644, st_size=24, ...}) = 0
unlink("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17x") = 0
link("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", "/root/.gnupg/pubring.kbx.lock") = 0
stat("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17", {st_mode=S_IFREG|0644, st_size=24, ...}) = 0
access("/root/.gnupg/pubring.kbx", F_OK) = -1 ENOENT (No such file or directory)
umask(077) = 022
open("/root/.gnupg/pubring.kbx", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
brk(0) = 0x7f7528fc5000
brk(0x7f7528fc8000) = 0x7f7528fc8000
umask(022) = 077
close(3) = 0
open("/root/.gnupg/pubring.kbx", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
ioctl(3, TIOCGWINSZ, 0x7fff3556c968) = -1 ENOTTY (Not a tty)
writev(3, [{"\0\0\0 \1\1\0\2KBXf\0\0\0\0W\30+\243W\30+\243\0\0\0\0\0\0\0\0", 32}, {NULL, 0}], 2) = 32
close(3) = 0
write(2, "gpg: keybox '/root/.gnupg/pubrin"..., 37gpg: keybox '/root/.gnupg/pubring.kbx) = 37
write(2, "' created\n", 10' created
) = 10
open("/root/.gnupg/pubring.kbx.lock", O_RDONLY) = 3
read(3, " 17\n60fbb80a7ebb\n", 24) = 24
close(3) = 0
getpid() = 17
unlink("/root/.gnupg/pubring.kbx.lock") = 0
unlink("/root/.gnupg/.#lk0x00007f7526f64f40.60fbb80a7ebb.17") = 0
access("/root/.gnupg/secring.gpg", F_OK) = -1 ENOENT (No such file or directory)
open("/dev/tty", O_RDWR) = 3
ioctl(3, TIOCGWINSZ, {ws_row=43, ws_col=174, ws_xpixel=0, ws_ypixel=0}) = 0
writev(3, [{"Note: Use \"gpg2 --full-gen-key", 30}, {"\" for a full featured key genera"..., 45}], 2Note: Use "gpg2 --full-gen-key" for a full featured key generation dialog.
) = 75
writev(3, [{"", 0}, {"\nGnuPG needs to construct a user"..., 59}], 2
GnuPG needs to construct a user ID to identify your key.
) = 59
writev(3, [{"Real name: ", 11}, {NULL, 0}], 2Real name: ) = 11
read(3,
|
The problem seems to be related to pinentry and the tty. The same command works perfectly with Ubuntu. tty in a Alpine Linux container displays /0 while tty in a Ubuntu container shows /dev/console
By first exporting a correct tty for gpg (export GPG_TTY=/dev/console) the command works and shows the password dialog.
| GPG Key Generation Fails on Alpine Linux Docker Image |
1,599,711,376,000 |
I use Thunderbid, Enigmail, GnuPG and pinentry.
When I receive encrypted message, how I can determine which algorithm is used:
for encryption
for checksuming (SHA1 or not)
for compression
|
I don't know of a method inside thunderbird, but storing the message as a file and dropping to the shell will reveal the information you're looking for.
Getting verbose
gpg -vv will output very verbose information on the input, including the information you're looking for.
An Example
An example of the output can be generated by encrypting and signing a message to your own key:
echo 'foo' | gpg --recipient a4ff2279 --encrypt --sign | gpg -vv
The slightly stripped output (removing bulky parts not relevant to the question at all) looks like:
:pubkey enc packet: version 3, algo 1, keyid CC73B287A4388025
data: [4095 bits]
[snip, gpg asking for passphrase]
gpg: public key encrypted data: good DEK
:encrypted data packet:
length: unknown
mdc_method: 2
gpg: encrypted with 4096-bit RSA key, ID A4388025, created 2014-03-26
"Jens Erat (born 1988-01-19 in Stuttgart, Germany)"
gpg: AES256 encrypted data
:compressed packet: algo=2
:onepass_sig packet: keyid 8E78E44DFB1B55E9
version 3, sigclass 0x00, digest 8, pubkey 1, last=1
:literal data packet:
mode b (62), created 1418376556, name="",
raw data: 4 bytes
gpg: original file name=''
foo
:signature packet: algo 1, keyid 8E78E44DFB1B55E9
version 4, created 1418376556, md5len 0, sigclass 0x00
digest algo 8, begin of digest 81 67
hashed subpkt 2 len 4 (sig created 2014-12-12)
subpkt 16 len 8 (issuer key ID 8E78E44DFB1B55E9)
data: [4095 bits]
gpg: Signature made Fri Dec 12 10:29:16 2014 CET using RSA key ID FB1B55E9
gpg: using subkey FB1B55E9 instead of primary key A4FF2279
[snip, trust validation]
gpg: binary signature, digest algorithm SHA256
gpg: decryption okay
Interpreting the Output
If GnuPG only prints algorithm IDs (like for the compression), these can be looked up in RFC 4880, Section "Constants". Specifically for this example, we will find use of following algorithms:
AES256 for symmetric encryption
MDC 2 means SHA1 for the Modification Detection Code, which is the only defined at this time
Compression algorithm 2, resolving to ZLIB
SHA256 for the signature
| How to learn encryption type from a mail message? |
1,599,711,376,000 |
My configuration:
Centos 6.5
gnugp2-2.0.14-6.el6_4.x86_64
gnupg2-smime-2.0.14-6.el6_4.x86_64
I configured gpg2 to use my signature key in smartcard gnupg V2.0.
I imported my gpg signature key to the rpm store.
I need to sign an rpm package using rpm --addsign myApp.rpm.
It works fine, but rpm prompts once for the smartcard PIN, and gpg2 (with pinentry programm) prompts three times for the smartcard PIN.
I expected that rpm --addsign passes the PIN (get in first prompt) to gpg2 and gpg2 doesn't ask again for the PIN.
Is it possible to have only one prompt to sign the rpm package with gpg2?
|
In order for the pin to be cached you need to run gpg-agent and your card should not have the forcesig bit set.
AFAIK, by default, the cards are shipped with the forcesig bit set, which is more secure. You can see this using the gpg --card-edit command and look for the entry Signature PIN. According to the manual:
Signature PIN
When set to "forced", gpg requests the entry of a PIN for each signature operation. When set to "non forced", gpg may cache the PIN as long as the card has not been removed from the reader.
You can change the bit by using:
$ gpg --card-edit
....
gpg: detected reader `MSI StarReader SMART [Smart Card Reader Interface]'
Version ..........: 2.0
Manufacturer .....: ZeitControl
Serial number ....: 0000201C
Name of cardholder: Anthony van der Neut
Language prefs ...: en
Sex ..............: please
URL of public key : http://anthon.home.xs4all.nl/publickey.asc
Login data .......: anthon
Private DO 1 .....: [not set]
Private DO 2 .....: [not set]
Signature PIN ....: forced <<<<< this is what should not be 'forced'
Key attributes ...: 2048R 2048R 2048R
Max. PIN lengths .: 32 32 32
PIN retry counter : 3 0 3
Signature counter : 2
....
gpg/card > admin
gpg/card > forcesig
(Shameless plug: for more details on securely setting up a card, see my rant gemini://ruamel.eu/rants/2014/setting_up_an_openpgp_smartcard_with_gnupg.gmi
| How to configure gpg2 to pass smartcard PIN unless pinentry programm? |
1,599,711,376,000 |
I am trying to install package on Redhat 5.5 using YUM but it always give me this error
[root@redhat64 Desktop]# yum install perl-Net-Server-0.97-1.el5.rf.noarch.rpm Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Examining perl-Net-Server-0.97-1.el5.rf.noarch.rpm: perl-Net-Server-0.97-1.el5.rf.noarch
Marking perl-Net-Server-0.97-1.el5.rf.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package perl-Net-Server.noarch 0:0.97-1.el5.rf set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package
Arch Version Repository Size
================================================================================
Installing:
perl-Net-Server
noarch 0.97-1.el5.rf /perl-Net-Server-0.97-1.el5.rf.noarch 357 k
Transaction Summary
================================================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total size: 357 k
Is this ok [y/N]: y
Downloading Packages:
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 6b8d79e6
Public key for perl-Net-Server-0.97-1.el5.rf.noarch.rpm is not installed
Note :: OS is 5.5 64bit running on virtual box and I have set GPGCHECK=0 in local YUM repository.
Output of Repository
[root@redhat64 ~]# cat /etc/yum.repos.d/* | grep -v "^#"
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/enterprise/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-debuginfo-beta]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Debug
baseurl=ftp://ftp.redhat.com/pub/redhat/linux/beta/$releasever/en/os/$basearch/Debuginfo/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-beta,file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[rhel-local.repo]
name=Local Repo
Baseurl=file:///RPMS
enabled=1
gpgcheck=0
Im using the Local.repo as my main packages repository
|
You need to install the Repoforge GPG key:
# rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
| Public key not found for RPM |
1,599,711,376,000 |
I am using the default _gpg completion file for zsh, which came with my zsh version 5.7.1-1 (debian 10). I have pasted the file here: https://ctxt.io/2/AABg86pPFQ
When I do gpg <TAB>, zsh completes files and directories in current directory. I would like to change that, so that:
a) if I use gpg without further arguments (which implies -d), then only *.gpg files in current dir are completed (not directories)
b) if I use -e or -c (implies encryption), only non-gpg files in current directory are completed (not directories)
c) for the rest, I guess the default behavior is oK
I have added following to my .zshrc:
zstyle ':completion::complete:gpg:*' file-patterns '*.(gpg|sig)(.)'
but that should only be the rule for case a)
How can I achieve behavior described above?
|
I have never edited zsh completion files so there might be some bugs
but that does what you want:
#compdef gpg gpgv gpg-zip gpg2=gpg
local curcontext="$curcontext" state line expl ret=1
local -a args allopts dups extra
typeset -A opt_args
if [[ $service = gpg-zip ]]; then
args=(
'--gpg[command to use instead of gpg]:command:_command'
'--gpg-args[gpg arguments]:gpg arguments:'
'--tar[command to use instead of tar]:command:_command'
'--tar-args[tar arguments]:tar arguments:'
'--list-archive[list archive contents]'
)
else
allopts=( $(_call_program options $words[1] --dump-options) )
args=(
'(-q --quiet)*'{-v,--verbose}'[increase amount of output]'
'(-q --quiet -v --verbose)'{-q,--quiet}'[reduce amount of output]'
'--keyring=[add specified file to list of keyrings]:file:_files'
'--'{status,logger}'-fd:file descriptor:_file_descriptors'
'--homedir:directory:_directories'
)
fi
[[ $service = gpgv ]] || args+=(
'(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]:files:_path_files -g "^(#i)*.gpg(-.)"'
'(-d,--decrypt)'{-d,--decrypt}'[decrypt file or stdin]:files:_path_files -g "(#i)*.gpg(-.)"'
'(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cipher only]:files:_path_files -g "^(#i)*.gpg(-.)"'
'(-s --sign)'{-s,--sign}'[make a signature]'
'*'{-r+,--recipient}'[specify user to encrypt for]:recipient:->public-keys'
'(-u --local-user)'{-u+,--local-user}'[use name as the user ID to sign]:user attachment:_users'
'(-o --output)'{-o+,--output}'[write output to file]:output file:_files'
'(-h --help)'{-h,--help}'[display usage information]'
'--version[print info on program version and supported algorithms]'
'*:filename _files:_path_files -g "(#i)*.gpg(-.)"'
)
[[ $service = gpg ]] && args+=(
'--decrypt-files[decrypt multiple files]'
'(-b --detach-sign)'{-b,--detach-sign}'[make a detached signature]'
--clear{,-}sign'[make a clear text signature]'
'--store[store only]'
'--verify[verify a signature]'
'--verify-files[verify a list of files]'
'(-f --encrypt-files)'{-f,--encrypt-files}'[encrypt files]'
'(-k --list-keys)'{-k,--list-keys}'[list all keys]'
'--list-public-keys[list all public keys]'
'(-K --list-secret-keys)'{-K,--list-secret-keys}'[list all secret keys]'
--list-sig{,nature}s'[lists keys and signatures]:key attachment:->public-keys'
'--list-options[modify what the various --list-* commands show]: :->option-list'
--check-sig{,nature}s'[list key, signatures and check them]:key attachment:->public-keys'
'--fingerprint[list all keys with their fingerprints]:key attachment:->public-keys'
'--list-packets[list only the sequence of packets]'
'--gen-key[generate a new pair key]'
'--edit-key[interactively edit a key]:key attachment:->public-keys'
'--sign-key[sign a key]:key attachment:->public-keys'
'--lsign-key[sign a key but mark as non-exportable]:key attachment:->public-keys'
'--delete-keys[remove key from public keyring]:key attachment:->public-keys'
'--delete-secret-keys[remove key from public & private keyring]:key attachment:->secret-keys'
'--delete-secret-and-public-keys:key attachment:->secret-keys'
'--gen-revoke[generate a revocation certificate]'
'--desig-revoke[generate a designated revocation certificate]'
'--passwd[change a passphrase]'
'--export[export all keys from all keyrings]'
'--send-keys[send keys to a keyserver]:key attachment:->public-keyids'
'--export-secret-keys:key attachment:->secret-keys'
'--export-secret-subkeys:key attachment:->secret-keys'
'--import[import a gpg key from a file]:attachment (file):_files'
'--fast-import[import a file without adding to trustdb]:attachment (file):_files'
'--fetch-keys[fetch key at URIs]:uri:'
--rec{eive,v}-keys'[receive a list of keys from a keyserver]:key attachment:->public-keyids'
'--refresh-keys[update all keys from a keyserver]'
'--search-keys[search for keys on a key server]'
'--update-trustdb[update the trust database]'
'--check-trustdb[unattended trust database update]'
'--fix-trustdb[fix a corrupted trust database]'
'--export-ownertrust[list the assigned ownertrust values in ASCII format]:file:_files'
'--import-ownertrust[update the trustdb with a file]:file:_files'
'--dearmor[de-Armor a file or stdin]'
'--enarmor[en-Armor a file or stdin]'
'--print-md[print message digests]:algorithm:->ciphers::file:_files'
'--print-mds[print message digests]::file:_files'
'--tofu-policy:policy:(good unknown bad ask auto):*:keys:->public-keys'
'--tofu-default-policy:policy:(good unknown bad ask auto)'
'--quick-generate-key:user-id: :algorithm:(default future-default rsa dsa elg ed25519 cv25519): : _values -s , usage - default sign auth encr::expiration'
'--quick-add-key:fingerprint: :algorithm:(default future-default rsa dsa elg ed25519 cv25519): : _values -s , usage - default sign auth encr::expiration'
'--gen-random:quality level:(0 1 2):count (bytes)' '--gen-prime'
'--warranty[print warranty info]'
'(-a --armor)'{-a,--armor}'[create ASCII armored output]'
'--default-key[specify default user ID for signatures]:key:->secret-keys'
'--default-recipient[specify default recipient]:recipient:->public-keys'
'--default-recipient-self[use default key as default recipient]'
'--no-default-recipient[reset default recipient]'
'*--encrypt-to[specify recipient]:key:->public-keys'
'(--encrypt-to)--no-encrypt-to[disable the use of all --encrypt-to keys]'
'-z[specify compression level]:compression level:((0\:no\ compression 1\:minimum 2 3 4 5 6\:default 7 8 9\:maximum))'
'(-t --textmode)'{-t,--textmode}'[use canonical text mode]'
'(-n --dry-run)'{-n,--dry-run}"[don't make any changes]"
'(-i --interactive --batch)'{-i,--interactive}'[prompt before overwriting files]'
'(-i --interactive --no-batch)--batch[use batch mode]'
'--no-tty[never output to tty]'
'(--batch)--no-batch[disable batch mode]'
'(--no)--yes[assume "yes" on most questions]'
'(--yes)--no[assume "no" on most questions]'
'--default-cert-check-level:check level:((0\:no\ claim 1\:no\ verification 2\:casual\ verification 3\:extensive\ verification))'
'--trusted-key[assume that the specified key is trustworthy]:long key id'
'--always-trust[skip key validation]'
'--keyserver[specify key server to use]:key server:_hosts'
'--keyserver-options[specify keyserver options]:options'
'--import-options[specify options for importing keys]:options'
'--export-options[specify options for exporting keys]:options'
'--photo-viewer:command:_command_names -e'
'--exec-path:path:_dir_list'
'--show-keyring[display keyring name when listing keys]'
'--secret-keyring[add specified file to list of secret keyrings]:file:_files'
'--charset:character set:(iso-8859-1 iso-8859-2 koi8-r utf-8)'
'--utf8-strings' '--no-utf8-strings[arguments are not in UTF8]'
'(--no-options)--options[specify file to read options from]:options file:_files'
"(--options)--no-options[don't read options file]"
'--'{attribute,passphrase,command}'-fd:file descriptor:_file_descriptors'
'--sk-comments[include secret key comments when exporting keys]'
'(--emit-version)--no-emit-version[omit version string in clear text signatures]'
'(--no-emit-version)--emit-version[force writing of version string in clear text signatures]'
'(-N --notation-data)'{-N,--notation-data}'[put parameter in signature]:name=value'
'(--no-show-notation)--show-notation[show key signature notations]'
"(--show-notation)--no-show-notation[don't show key signature notations]"
'--set-policy-url:policy URL'
'--set-filename[specify file which is stored in messages]:file:_files'
'--completes-needed:number' '--marginals-needed:number' '--max-cert-depth:number'
'--'{{,disable-,s2k-}cipher,{,s2k-,cert-}digest,disable-pubkey}'-algo:cipher:->ciphers'
'--s2k-mode:value'
'--compress-algo:compression algorithm:((0\:disable\ compression 1\:zlib 2\:rfc1950))'
'--personal-'{cipher,digest,compress}'-preferences:string'
--{card-edit,edit-card}'[present smartcard menu]' '--card-status[show smartcard content]'
'--change-pin[present menu to change smartcard pin]'
'--list-config[display internal configuration parameters]'
'--hidden-recipient[hidden recipient]:recipient:->public-keys'
'--default-preference-list:string'
'--fetch-keys:URIs'
'--hidden-encrypt-to:recipient:->public-keys'
'--compress-level:integer'
'--bzip2-compress-level:integer'
'--default-cert-level:integer'
'--max-output[maximum output generated when processing file]:bytes:'
'--gpg-agent-info[override GPG_AGENT_INFO]:'
'--primary-keyring:file:_files'
'--verify-options: :->verify-options'
'--debug:flags:' '--status-file:file:_files'
'--attribute-file:file:_files' '--load-extension:file:_files'
'--s2k-count:integer'
'--sig-notation:name=value:' '--cert-notation:name=value:'
'--passphrase-file:file:_files' '--passphrase-repeat:integer:'
'--command-file:file:_files' '--trustdb-name:file:_files'
'--trust-model:trust model:(pgp classic tofu tofu+pgp direct always auto)'
'--sig-policy-url:string:' '--cert-policy-url:string:'
'--sig-keyserver-url:string:' '--comment[comment]:comment:'
'--no-comments[disable comments]'
'--logger-file[write log to file]:file:_files'
'--rebuild-keydb-caches[create signature caches in keyring]'
'--default-keyserver-url:name:'
'--display-charset[set native charset]:charset:((iso-8859-1 iso-8859-2 iso-8859-15 koi8-r utf-8))'
'--ungroup[remove group]:group name:'
'--no-groups[remove all entries from --group list]'
'--enable-progress-filter[enable progress status output]'
'--multifile[process multiple files]'
'--keyid-format[key id format]:key format:((short 0xshort long 0xlong))'
'--exit-on-status-write-error[exit immediately on error write]'
'--limit-card-insert-tries:integer'
'--reader-port[card reader port]:port'
'--ctapi-driver[file to use to access smartcard reader]:file:_files'
'--pcsc-driver[file to use to access smartcard reader]:file:_files'
'--auto-key-locate:parameters'
'--dump-options[show all options]'
)
extra=( ${${${args#\([^\)]#\)}#\*}%%[:=\[]*} )
extra=( ${allopts:|extra} )
_arguments -C -s -S -A "-*" $args $extra && ret=0
if [[ $state = args ]]; then
if (( ${+opt_args[--export]} || ${+opt_args[-k]} || ${+opt_args[--list-keys]} || ${+opt_args[--list-public-keys]} )); then
state=public-keys
elif (( ${+opt_args[--list-secret-keys]} )); then
state=secret-keys
else
_files && return
fi
fi
# We need to keep some arguments to get a consistent list of keys
# etc.
local -a needed
integer krind=${words[(I)--keyring(|=*)]}
needed=(${words[(r)--no-default-keyring]})
if (( krind )); then
# We have a --keyring option. We can't be completing its
# argument because that was handled above, so it must be complete.
if [[ $words[krind] = --keyring ]]; then
if [[ -n $words[krind+1] ]]; then
needed+=(--keyring=$words[krind+1])
fi
else
needed+=($words[krind])
fi
fi
case "$state" in
public-keys)
local public_keys_lines=(${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"})
local -a uids emails
local i j parts current_uid
for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do
parts=("${(@s.:.)public_keys_lines[$i]}")
if [[ ${parts[1]} == "fpr" ]]; then
current_uid="${parts[10]}"
i=$((i + 1))
parts=("${(@s.:.)public_keys_lines[$i]}")
while [[ ${parts[1]} == "uid" ]]; do
uids+=("${current_uid}")
emails+=("${parts[10]}")
i=$((i + 1))
parts=("${(@s.:.)public_keys_lines[$i]}")
done
fi
done
_describe -t public-keys 'public key' emails uids
;;
secret-keys)
local secret_keys_lines=(${(f)"$(_call_program secret-keys ${(q)words[1]} ${(q)needed} --list-secret-keys --list-options no-show-photos --with-colons)"})
local -a uids emails
local i j parts current_uid
for (( i = 1; i < ${#secret_keys_lines[@]}; ++i )); do
parts=("${(@s.:.)secret_keys_lines[$i]}")
if [[ ${parts[1]} == "fpr" ]]; then
current_uid="${parts[10]}"
i=$((i + 1))
parts=("${(@s.:.)secret_keys_lines[$i]}")
while [[ ${parts[1]} == "uid" ]]; do
uids+=("${current_uid}")
emails+=("${parts[10]}")
i=$((i + 1))
parts=("${(@s.:.)secret_keys_lines[$i]}")
done
fi
done
_describe -t secret-keys 'secret key' emails uids
;;
ciphers)
_wanted ciphers expl cipher compadd \
${${(s.,.)${(M)${(f)${"$(_call_program ciphers ${(q)words[1]} ${(q)needed} --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return
;;
(public-keyids)
local public_keys_lines=(${(f)"$(_call_program public-keyids ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"})
local -a uids emails
local i j parts current_uid
for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do
parts=("${(@s.:.)public_keys_lines[$i]}")
if [[ ${parts[1]} == "fpr" ]]; then
current_uid="${parts[10]}"
i=$((i + 1))
parts=("${(@s.:.)public_keys_lines[$i]}")
while [[ ${parts[1]} == "uid" ]]; do
uids+=("${current_uid}")
emails+=("${parts[10]}")
i=$((i + 1))
parts=("${(@s.:.)public_keys_lines[$i]}")
done
fi
done
_describe -t public-keyids 'public key' emails uids
;;
(option-list)
_sequence _wanted options expl option \
compadd - {no-,}show-{photos,usage,policy-urls,{std,user}-notations,keyserver-urls,uid-validity,unusable-{uids,subkeys},keyring,sig-{expire,subpackets}} && return
;;
(verify-options)
_sequence _wanted options expl option \
compadd - {no-,}show-{photos,policy-urls,{std,user}-notations,keyserver-urls,uid-validity,unusable-uids,primary-uid-only} {no-,}pka-{lookups,trust-increase} && return
;;
esac
return ret
The file is huge so it's hard to notice what was changed at the first
glance so you can use diff tool to quickly see:
$ diff /usr/share/zsh/5.8/functions/_gpg /usr/share/zsh/5.8/functions/_gpg.bak
27,29c27,29
< '(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]:files:_path_files -g "^(#i)*.gpg(-.)"'
< '(-d,--decrypt)'{-d,--decrypt}'[decrypt file or stdin]:files:_path_files -g "(#i)*.gpg(-.)"'
< '(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cipher only]:files:_path_files -g "^(#i)*.gpg(-.)"'
---
> '(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]'
> {-d,--decrypt}'[decrypt file or stdin]'
> '(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cipher only]'
36d35
< '*:filename _files:_path_files -g "(#i)*.gpg(-.)"'
179c178
< _arguments -C -s -S -A "-*" $args $extra && ret=0
---
> _arguments -C -s -S -A "-*" $args $extra '*:args:->args' && ret=0
| zsh completion for gpg |
1,599,711,376,000 |
I'm using Debian-based Docker image, and I have only one usable key in the keyring:
$ gpg -K
/tmp/test-keyring/pubring.kbx
-------------------------------
sec> rsa2048 2012-01-16 [C] [expires: 2024-05-15]
CB522FE0379DDF40A93400D7E4BC91FACDA9A65B
Card serial no. = 00nn 00nnnnnn
uid [ unknown] John Doe <[email protected]>
ssb# rsa2048 2012-01-16 [S] [expires: 2024-05-14]
ssb rsa3072 2012-01-16 [S] [expires: 2024-05-15]
As you can see here, there are three keys:
Primary key tagged with > resides on the smart card. It is marked as certify-only key, therefore it can't be used for signing.
Private part for the second secondary signing key, tagged with #, isn't present here. Therefore it can't be used for signing.
Third secondary signing key has a private part available. This is the only key here that can be used for signing.
Again, last key here is the only key usable for signing purposes.
Alas, for some reason GnuPG fails to see it:
$ echo test | gpg --clearsign
gpg: no default secret key: Unusable public key
gpg: [stdin]: clear-sign failed: Unusable public key
Yet has no problem signing if I specify a user ID directly:
$ echo test | gpg --clearsign --default-key [email protected]
gpg: using "[email protected]" as default secret key for signing
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
test
-----BEGIN PGP SIGNATURE-----
The manual says it should be working out of the box:
--default-key name
Use name as default user ID for signatures. If this is not used the default user ID is the first user ID found in the secret keyring.
I'm using GnuPG 2.2.19:
$ gpg --version
gpg (GnuPG) 2.2.19
libgcrypt 1.8.5
I've applied a known Docker workaround with GPG_TTY, to no avail.
What do I do to make it work?
|
The problem disappears if I happen to unplug the smart-card, and repeat signing operation. This was a GnuPG bug, and it appears that it is going to be fixed in the next release.
Dockerized environment has nothing to do with this.
| GnuPG fails to find default key to sign when using a smart card, yet I have only one. What am I doing wrong? |
1,599,711,376,000 |
I've just downloaded a FreeBSD 11.0 iso file from the FreeBSD website. I've also obtained the signed SHA512 and SHA256 checksum files. The website says that the checksum files are PGP-signed. How do I verify the integrity of the downloaded iso? Where do I get the public key to verify the signature in the checksum files?
|
If you are in a Linux / Unix-like system,
sha256sum /path/to/freebsd.iso
sha512sum /path/to/freebsd.iso
will print the checksums.
The public PGP key is likely one of these.
| How to verify FreeBSD iso download? |
1,599,711,376,000 |
I would like to use the "pass" password manager. I don't seem to be able
to get pass to recognize my public key.
$ gpg2 --list-keys
/home/johndoe/.gnupg/pubring.gpg
-------------------------------
pub rsa4096/3AD31D0B 2011-02-08 [SCE]
uid [ unknown] Fedora-SPARC (15) <[email protected]>
sub elg4096/A9DAE699 2011-02-08 [E]
... lots of other keys like the one above and then ...
pub rsa2048/27FA9292 2016-03-31 [SC]
uid [ultimate] John Doe <[email protected]>
sub rsa2048/7C8FD1D9 2016-03-31 [E]
$ pass git init 27FA9292
Reinitialized existing Git repository in /home/johndoe/.password-store/.git/
pass insert pubs/checkbook
Enter password for pubs/checkbook:
Retype password for pubs/checkbook:
gpg: captain Password Storage Key: skipped: No public key
gpg: [stdin]: encryption failed: No public key
fatal: pathspec '/home/johndoe/.password-store/pubs/checkbook.gpg' did not match any files
captain is the hostname. Why can pass not find my public key?
Thank you.
|
You can't compress the two commands into one. You need to first initialise the pass store with your key and then, separately, initialise the git repository. Because, as the manual states, pass git only takes git-command-args.
So, the correct approach requires two steps:
pass init YOUR_KEY
pass git init
| gpg problem in using pass password manager |
1,599,711,376,000 |
I'm started to use unix password manager Pass
Some passwords are not critical to me and I'm using them very often
So it's became very annoying to me to type passphrase to get some password.
Is there a way to type passphrase only once?
|
hymie is right, the question is related to gpg.
The solution is tricky for me, so here's one for OSX:
Install pinentry-mac
brew install pinentry-mac
Create file ~/.gnupg/gpg-agent.conf with lines:
pinentry-program /usr/local/bin/pinentry-mac
default-cache-ttl 86400
max-cache-ttl 86400
When pinentry program requires a passphrase, check box to keep this passphrase
| Pass, how to cache passphrase |
1,599,711,376,000 |
I am using a Debian unstable with Iceweasel (38.2.0esr-1) and the Enigmail plugin (2:1.8.2-3) from the distribution packages. I recently upgraded my system and got a new version of the gnupg2 package (2.1.7-2, previous was 2.0.28-2) and I ran into problems when trying to use my private key (encrypt, decrypt, sign messages) in Enigmail since then. The error message is:
Enigmail: Error - no matching private/secret key found to decrypt message;
click on 'Details' button for more information
And, the 'Details' button was giving the following error message:
Enigmail Security Info
Error - no matching private/secret key found to decrypt message
gpg: decryption failed: No secret key
Note: The message is encrypted for the following User ID's / Keys:
0xAAAAAAAAAAAAAAAA (Surname Name <[email protected]),
0xAAAAAAAAAAAAAAAA
Note also, that, if I save the e-mail in a flat file and use the gpg2 --decrypt command line, it works like a charm without any visible problem.
I looked in the Debian BTS about Enigmail and found a bug with similar characteristics (Debian Bug #794627). It has not been solved because the maintainer cannot reproduce the bug.
I tried several things with no success, so if you encounter this bug and find something about it, I would be pleased to know how to solve it. Any input is welcome.
|
In fact, the problem is linked to the usage of the gnome3-pinentry software when agent has no default DBUS_SESSION_BUS_ADDRESS.
Here is the thread on the Debian BTS (Bug Tracking System) Website about this problem.
It finally turned out that the default pinentry software is working as expected, but the Gnome3 version has some quirks about dispatching some variables. Here is the patch applied by the Debian Enigmail maintainer to fix the problem:
enigmail (2:1.8.2-4) unstable; urgency=medium
* pass through {GTK,QT}_IM_MODULE, XMODIFIERS, and
DBUS_SESSION_BUS_ADDRESS so that modern pinentry works. (Closes: #794627)
* correct reported version number of enigmail
-- Daniel Kahn Gillmor <[email protected]> Thu, 20 Aug 2015 00:23:48 +0200
| Enigmail plugin does not recognize anymore my private key |
1,599,711,376,000 |
I already have a production version of GPG from a previous installation.
I would like to build and test the last version of GPG without interfering with the production one.
I am performing this test on MacOS X 10.10.3, but ideally this validation process should be independent of the OS.
I created a new repository directory different of the one where the running GPG is:
mkdir /local/gpg2
I downloaded the 4 required libraries and the gnupg archive:
libgpg-error-1.19
libgcrypt-1.6.3
libksba-1.3.3
libassuan-2.2.1
gnupg-2.0.27
I successfully built and installed libgpg-error:
cd libgpg-error-1.19
./configure --prefix=/local/gpg2
make
make install
and started to build libgcrypt:
cd ../libgcrypt-1.6.3
./configure --prefix=/local/gpg2
and this process fails with:
checking for gpg-error-config... no
checking for GPG Error - version >= 1.11... no
configure: error: libgpg-error is needed.
See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .
I checked config.log where:
exec_prefix=NONE
prefix='/local/gpg2'
libdir='${exec_prefix}/lib'
and everything seems correct.
Where is this configuration problem coming from?
|
Since you're installing in non-standard locations, you'll need to tell each configure script where to find things. ./configure --help should give an indication of the appropriate option; for libgcrypt you'd run
./configure --prefix=/local/gpg2 --with-libgpg-error-prefix=/local/gpg2
Except that because of a bug in libgcrypt's configure script, only --with-gpg-error-prefix works, so you need to run
./configure --prefix=/local/gpg2 --with-gpg-error-prefix=/local/gpg2
The bug is already fixed in upstream's repository; it's #1467.
| Installation of GPG alongside a running one: configure problem? |
1,599,711,376,000 |
Thunderbird cannot search PGP-encrypted emails. Hence, I was considering copying all my emails from IMAP to local storage, then decrypting them all locally, so that they are searchable. Is this possible?
Thunderbird stores email folders as a single mbox file. I attempted gpg -d mbox_file, but this only decrypted a single email, and then failed with an error as follows.
gpg: [don't know]: invalid packet (ctb=46)
gpg: decryption failed: Bad signature
gpg: packet(3) too short
N.B. the mbox also contains non-encrypted email. I could perhaps filter these out from within Thunderbird, but the solution would preferably deal with this elegantly.
|
As of 2020 (sorry, I've no idea when this function was added) enigmail has a "decrypt to folder" option. (At the very bottom of the context menu.)
And you can select all messages in a folder, then use it to decrypt all messages in bulk.
(My search found your question as I'm wanting to do the opposite: take a directory of plain text messages and encrypt them all, such that enigmail is needed to read them.)
| How can I PGP decrypt an entire mbox? |
1,599,711,376,000 |
I've copied .gnupg from machine A to B.
Now on the machine B gpg --list-keys lists my key but gpg --list-secret-key won't unlike on machine A.
|
You should do export and import
gpg --export-secret-keys <keyid> > my.key
scp my.key remote:~/
# on remote
gpg --import my.key
gpg --list-secret
| gpg --list-secret-keys won't list keys |
1,599,711,376,000 |
I create a pair keyring with the new embedded tool from Thunderbird and export it into a file (.asc by default and readable).
Then I import these keys with gpg, finally I export again these keys with gpg --export --armor options.
I compare the two readable public key coming from both methods and it appears the first characters up to the first / differ. Also the last characters at the very last line after the = differs. The same arises for private keys. I don't understand why.
Somebody could clarify this. I tried to find on the web the "structure" of the public key that might encoded software something like heading information?
Also, which public key should I upload on a pgp server?
Sincerely.
|
I think the difference between the public key blocks is dis-interesting. You aren't meant to decode, read and understand the ascii contained in the PGP public key block. You certainly aren't expected to compare each individual character of the block. When manually comparing PGP keys, you compare the fingerprint only. With GPG this is found by using the --fingerprint command instead of --export. I don't know how it's done with thunderbird.
I think you can upload either pgp public key to the keyserver without any impact.
If you don't trust that last sentence (I can understand why you wouldn't take a stranger's word for it ... you are a PGP user), then upload the version from Thunderbird. That's because Thunderbird generated the public/private key pair and so the public key from thunderbird is certain to match the private key from Thunderbird.
| Different PGP public keys vs program used |
1,599,711,376,000 |
I am using gpg -
$ gpg --version
gpg (GnuPG) 2.2.12
libgcrypt 1.8.4
I am trying to understand the difference between the two commands :
$ gpg --list-key
and:
$ gpg --fingerprint
from whatever little I see, I don't see any difference between two outputs. Am I looking at something wrong ?
|
The --fingerprint option prints the fingerprint into 10 groups of 4 caracters to easily verify the gpg key.
| which part is the fingerprint in gpg public key |
1,599,711,376,000 |
So I guess I deleted or corrupted the gpg keys I had for *.debian.org, which makes apt-get update yield
Ign http://ftp.fr.debian.org jessie InRelease
Réception de : 1 http://security.debian.org jessie/updates InRelease [63,1 kB]
Réception de : 2 http://ftp.debian.org jessie-backports InRelease [166 kB]
Réception de : 3 http://ftp.fr.debian.org jessie Release.gpg [2 434 B]
Ign http://security.debian.org jessie/updates InRelease
Réception de : 4 http://ftp.fr.debian.org jessie-updates InRelease [145 kB]
Ign http://security.debian.org jessie/updates/main Sources/DiffIndex
Ign http://ftp.debian.org jessie-backports InRelease
Ign http://security.debian.org jessie/updates/main amd64 Packages/DiffIndex
Err http://ftp.fr.debian.org jessie-updates InRelease
Réception de : 5 http://ftp.debian.org jessie-backports/main amd64 Packages/DiffIndex [27,8 kB]
Atteint http://ftp.fr.debian.org jessie Release
Ign http://ftp.fr.debian.org jessie Release
Réception de : 6 http://ftp.debian.org jessie-backports/contrib amd64 Packages/DiffIndex [25,3 kB]
Ign http://ftp.fr.debian.org jessie/main Sources/DiffIndex
Ign http://ftp.fr.debian.org jessie/main amd64 Packages/DiffIndex
Atteint http://security.debian.org jessie/updates/main Translation-en
Atteint http://security.debian.org jessie/updates/main Sources
Atteint http://security.debian.org jessie/updates/main amd64 Packages
Atteint http://ftp.debian.org jessie-backports/contrib Translation-en
Atteint http://ftp.fr.debian.org jessie/main Translation-fr
Atteint http://ftp.fr.debian.org jessie/main Translation-en
Ign http://security.debian.org jessie/updates/main Translation-fr_FR
Ign http://security.debian.org jessie/updates/main Translation-fr
Atteint http://ftp.debian.org jessie-backports/main Translation-en
Atteint http://ftp.fr.debian.org jessie/main Sources
Atteint http://ftp.fr.debian.org jessie/main amd64 Packages
Ign http://ftp.fr.debian.org jessie/main Translation-fr_FR
Ign http://ftp.debian.org jessie-backports/contrib Translation-fr_FR
Ign http://ftp.debian.org jessie-backports/contrib Translation-fr
Ign http://ftp.debian.org jessie-backports/main Translation-fr_FR
Ign http://ftp.debian.org jessie-backports/main Translation-fr
430 ko réceptionnés en 2s (175 ko/s)
Lecture des listes de paquets…
W: Erreur de GPG : http://security.debian.org jessie/updates InRelease : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY (SOME hexadecimals) NO_PUBKEY (SOME hexadecimals)
W: Erreur de GPG : http://ftp.debian.org jessie-backports InRelease : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY (SOME hexadecimals) NO_PUBKEY (SOME hexadecimals)
W: Une erreur s'est produite lors du contrôle de la signature. Le dépôt n'est pas mis à jour et les fichiers d'index précédents seront utilisés. Erreur de GPG : http://ftp.fr.debian.org jessie-updates InRelease : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY (SOME hexadecimals) NO_PUBKEY (SOME hexadecimals)
W: Erreur de GPG : http://ftp.fr.debian.org jessie Release : Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible : NO_PUBKEY (SOME hexadecimals) NO_PUBKEY (SOME hexadecimals) NO_PUBKEY (SOME hexadecimals)
W: Impossible de récupérer http://ftp.fr.debian.org/debian/dists/jessie-updates/InRelease
W: Le téléchargement de quelques fichiers d'index a échoué, ils ont été ignorés, ou les anciens ont été utilisés à la place.
"Les signatures suivantes n'ont pas pu être vérifiées car la clé publique n'est pas disponible" roughly translates as "following signatures couldn't be checked because public key isn't available".
How can I revert those mistakes ?
Update : I did
# wget http://ftp.fr.debian.org/debian/pool/main/d/debian-archive-keyring/debian-archive-keyring_2017.5~deb8u1_all.deb
# dpkg -i debian-archive-keyring_2017.5~deb8u1_all.deb
But nothing changed. I suspect what caused the whole thing is
# curl -s https://www.dotdeb.org/dotdeb.gpg | apt-key remove
to remove the gpg key I just added few minutes before.
|
Since you already reinstalled the debian-archive-keyring package, the actual key files should now be in place. But the reinstallation failed to re-add the keys as trusted, possibly because of certain conditions in the postinst script in the package that seem to be related to migration from Debian squeeze to jessie.
You'll probably need to do this (or something very similar):
# cd /etc/apt/trusted.gpg.d
# for i in *.gpg ; do apt-key add $i; done
If the actual keys are still missing, the brute-force way is to extract the package manually:
mkdir /tmp/workdir
cd /tmp/workdir
ar x /some/where/debian-archive-keyring_2017.5~deb8u1_all.deb
tar xvf data.tar.xz
Now you should definitely have the key files in directory /tmp/workdir/etc/apt/trusted.gpg.d/. Copy them into place and then use the apt-key add command as suggested above.
| How can I recover (or reset) the GPG keys of *.debian.org? |
1,599,711,376,000 |
I missed expiration date of my gpg key and have to generate a new one afterwards. Now I want to establish trust between my old and new key.
Naive call like
gpg --local-user DE5A457C --sign-key BCBE2B4A
ends in error message
gpg: skipped "DE5A457C": unusable secret key
How do I force gpg to sign a new key with an old, expired one?
|
I don't know if you can that, it's kind of violating the point of setting an expiry date. But you can probably trick gpg by running it in some kind of virtual machine that allows you to set the time to shortly before the old key expired. I don't know if gpg will let you sign a key that's not yet valid, but then you'll just have to make a new new key in that virtual machine and use that instead of BCBE2B4A.
| Signing new key with an old expired one [duplicate] |
1,599,711,376,000 |
I use a script to decrypt my password for offlineimap, but somehow it's not working anymore ...
The file was encrypted with
gpg --symmetric password
For offlineimap I use this combination.
gpg --quiet --batch --no-tty --for-your-eyes-only --decrypt password.gpg
On Linux it's working like it should, but on FreeBSD I get the following error:
gpg --quiet --batch --no-tty --for-your-eyes-only --decrypt ~/.mail-accounts/xxxxxx/password.gpg
gpg: can't query passphrase in
batch mode gpg: decryption failed: bad key
Am I missing something?
gpg --version gpg (GnuPG) 1.4.19
---COPYRIGHT INFO ---
Home: ~/.gnupg Supported algorithms: Pubkey:
RSA, RSA-E, RSA-S, ELG-E, DSA Cipher: IDEA, 3DES, CAST5, BLOWFISH,
AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256 Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed,
ZIP, ZLIB, BZIP2
I use the default gpg.conf without any changes.
It's not only working in offlineimap, also in my terminal and everywhere. ( on linux it's working)
Edit:
Link to python file: https://github.com/tarruda/dot-files/blob/master/mail/offlineimap.py ( not me )
Same script found on stackexange.
Encrypt OfflineIMAP Password
The call in offlineimap
remotepasseval = decrypt_password("[email protected]")
The idea behind is, that it's encrypted with "symmetric".
When offlineimap is starting the python script an pinentry window opens and asks for the pw.
But the pinentry window isn't starting like on linux.
On linux it is the same version only differ in Minor version.
In gpg 1.4.19 also the --batch option is available and has worked before, but i don't know what happens.
|
The --batch option was added in gpg v2. Prior to that, in v1, there is a --no-use-agent option which you might need if you're doing scripted operations.
That said, I don't understand how you're entering the key at time of decryption. ...? You're using --no-tty (which prevents gpg from asking you anything) but at least according to what you shared with us, you're not giving gpg a passphrase. That's a problem.
| Not possible to use batch mode?! FreeBSD gpg 1.4.19 |
1,599,711,376,000 |
I just used gpg2 --gen-key to generate a 2048 bit RSA key pair on an OS running on a live cd (Tails). This happened much faster than I expected. When I have done this before on a regular machine it takes a bit of time, and I typically need to wait and briefly do something else. I think that is because it takes some time to generate the required amount of randomness.
Does a live cd have some unusual process such that the boot process generates more than normal randomness? Or is it possible that it is using /dev/urandom instead? As far as I was aware, gpg uses /dev/random which is why it can take some time to generate keys.
|
I found the answer: Tails comes packaged with the random number generator 'haveged'.
http://www.reddit.com/r/tails/comments/2oxr7n/how_does_tails_generate_gpg_keys_so_fast/
I have edited the question's title to reflect that this is particular to Tails.
Here is some discussion of whether the HAVEGED algorithm is any good: https://crypto.stackexchange.com/questions/8083/quality-of-randomness-on-a-linux-system-with-haveged
The conservative approach taken by gpg in using /dev/random may be overkill in many situations, compared with using /dev/urandom but from the specific point of view of a live CD environment used for gpg key generation without time constraints, using haveged seems unnecessary.
So it seems to me the simplest solution is to kill the haveged process in Tails, wait for /proc/sys/kernel/random/entropy_avail to deplete, and then let gpg just do what it normally does.
| gpg key generation on Tails live cd - why so quick? |
1,599,711,376,000 |
I am using zsh with oh-my-zsh on OSX. I installed gnupg2 from homebrew giving me the executable gpg2. Unfortunately zsh auto completion appears to only support gpg (even though that executable is not even installed). Is there a way to enable zsh auto completion for gpg2. Is there some sort of oh-my-zsh plugin for this?
|
Gpg 2.x has almost the same command line options as gpg 1.x, you're unlikely to encounter the very few options that have changed. So declare gpg2 as having the same completions as gpg. In your .zshrc, after the compinit line, add
compdef gpg2=gpg
If you have no compinit line (it may be somewhere deep in the bowels of oh-my-zsh), put this after the inclusion of oh-my-zsh components.
| Zsh gpg2 autocompletion |
1,599,711,376,000 |
From the documentation, I can run gpg-agent with custom config like this and I think this is the official way:
The following gpg-agent.conf contains this:
allow-preset-passphrase
default-cache-ttl 34560000
max-cache-ttl 34560000
and to run gpg-agent with custom config:
#!/bin/bash
GPG_CONFIG_FILE="/opt/gpg-agent.conf"
gpg-agent --options $GPG_CONFIG_FILE --daemon
From my observation, the gpg-agent reads the custom config perfectly with no issue.
But, then I notice that if a gpg-agent is not running, then when I run a gpg command it will automatically run gpg-agent. This are example of commands that will call gpg-agent and start it automatically:
1) echo RELOADAGENT | gpg-connect-agent # Reload and forget passphrase of gpg-agent
2) KEY_GRIP=$(gpg --with-keygrip --list-secret-keys $KEY_ID | grep -Pom1 '^ *Keygrip += +\K.*') # List key grip for that key_id
The problem is the above commands did not run gpg-agent with custom config. I'm writing a bash script where the config will be generated with predefined value automatically inside the script own path (if it does not exist). So the script will only use this custom config not in ~/.gnupg.
$ ls
myscript.sh
conf/gpg-agent.conf
Question:
How do I make the gpg-agent to use custom config when running the above example commands ?
If question 1) is not possible, how do I prevent gpg-agent from running when executing the commands example given above that will automatically run gpg-agent ?
|
This has been more than a year. So, I solved this issue. The problem is caused by bug using the --daemon option as described in here: https://dev.gnupg.org/T5076,
In brief, gpg-agent should not spawn another process if an existing process is already there when we try to execute gpg command but it was stubborn not to use the existing gpg-agent process and create its own random process without using the custom config.
So the solution for systemd user in my case, I need to use the --supervised option when starting gpg-agent. Never ever use the --daemon option.
More details:
It is not straightforward to use the --supervised option like you run it using --daemon option. This supervised mode requires the service file and socket file to communicate each other and it must be enabled through systemctl. Here are the systemd files (this link described everything how to enable it):
https://github.com/gpg/gnupg/tree/master/doc/examples/systemd-user
So I can modify the gpg-agent.service to use custom option, then start gpg-agent using systemctl --user start gpg-agent. After that, every gpg commands will use this process instead of creating the new one. Too see the current process ID of the running gpg-agent I can do this:
systemctl --user status gpg-agent
So, the above answered my previous first and second questions. The second question would not prevent gpg-agent from running, but it will not create an extra gpg-agent process as this is what I was trying to solve previously because I had multiple gpg-agent process running that caused error in passphrase validation when it was running using --daemon option; The error that I mentioned here also described in the gpg bug tracker above. So my objective from the 2nd question was trying to prevent every gpg command to start gpg-agent automatically so that I can start them manually. But I don't need this method anymore when using --supervised option.
| How to run gpg agent with custom config when the agent starts automatically after running a specific gpg command? |
1,599,711,376,000 |
For (slightly) increased security, I would like to have better control of the lifetime of any unlocked keys, depending on the task being performed. Ideally, I would start an interactive sub-shell, do any tasks involving secrets, then have all unlocked keys be cleared automatically when the sub-shell exits.
I know that one can manually clear cached passphrases using gpg-connect-agent, but AFAIK that requires each key to be specified explicitly. Another option would be to set a sort cache expiry time using the --default-cache-ttl or --max-cache-ttl options for gpg-agent; but generally that means either setting a long TTL, or being asked for the same passphrase more than once.
I seem to remember that a long time ago it was possible to specify an alternative gpg-agent socket path and basically start an independent session, but that does not seem to be possible any more; newer versions seem to use a fixed path that cannot change.
So, what am I missing? Is there a way to achieve what I want?
|
While I do not have a full solution, I did find a workaround:
By using an alternate home directory for GnuPG via the --homedir parameter or the GNUPGHOME environment variable, one can force GnuPG to use a different set of key storage files and associated agent socket paths. With that in mind, I can start a shell inside a new gpg-agent session:
gpg-agent \
--homedir /my/other/keys \
--default-cache-ttl 86400 \
--max-cache-ttl 86400 \
--daemon \
\
/bin/bash
Any entered passphrases will either expire if the specified TTL passes (one day in this example), or will be "forgotten" when the new shell exits, as that will cause the parent gpg-agent instance to self-terminate.
The reason I do not consider this a full solution is that it forces the use of a separate keyring. However, that works perfectly for my specific use case and, therefore, I did not investigate further.
It may be possible to achieve the full effect of independent sessions for the same keyring by having symlinks to the default GnuPG keyring, provided enough care is taken w.r.t. maintaining any locking between different gpg-agent instances. I'll leave that as an exercise to the reader...
| Controlling the lifetime of keys unlocked in a GnuPG agent |
1,518,116,339,000 |
When encrypting a file with symmetric key, most common utilities (such as gpg, mcrypt, etc) store information in the encrypted message which can be used to verify integrity of the key during decryption. E.g., if the wrong key is entered during decryption, gpg will retort with:
gpg: decryption failed: bad key
Suppose I am encrypting a file containing a string which is random. Then the key integrity check used in the standard utilities adds a vulnerability.
Is there a common utility which will not store any information or redundancy for verifying key/message integrity (and so will "decrypt" an encrypted file for any supplied key)?
|
As an alternative to my other answer, I'd like to offer something else. Something beautiful ... dm-crypt.
Plain dm-crypt (without LUKS) doesn't store anything about the key; on the contrary, cryptsetup is perfectly happy to open a plain device with any password and start using it. Allow me to illustrate:
[root:tmp]# fallocate -l 16M cryptfile
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pa55w0rd"
Note: Your cryptfile has to be greater or equal than 512 bytes. I assume due to the minimum sector size cryptsetup enforces.
At this point, you would want to write all your random data out to the /dev/mapper/cfile-open. It would seem prudent to me that you size the original cryptfile appropriately ahead of time so that you will use all the space; however, you could just as easily treat this as another added bit of security-through-obscurity and make a note of exactly how much data you wrote. (This would only really work if the underlying blocks were already semi-random, i.e., if you're not going to completely fill the file, you should create it with openssl rand or dd if=/dev/urandom instead of fallocate.) ... You could even use dd to start writing somewhere in the middle of the device.
For now, I'll do something simpler.
[root:tmp]# cryptsetup status cfile-open
/dev/mapper/cfile-open is active.
type: PLAIN
cipher: aes-cbc-essiv:sha256
keysize: 256 bits
device: /dev/loop0
loop: /tmp/cryptfile
offset: 0 sectors
size: 32768 sectors
mode: read/write
[root:tmp]# b $((32768*512))
B KiB MiB GiB TiB PiB EiB
16777216 16384.0 16.00 .01 0 0 0
[root:tmp]# ll cryptfile
-rw-r--r--. 1 root root 16777216 Feb 21 00:28 cryptfile
[root:tmp]# openssl rand -out /dev/mapper/cfile-open $((32768*512))
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 00 1d 2d 11 ac 38 c4 d3 cc 81 4f 32 de 64 01 ca |..-..8....O2.d..|
00000010
[root:tmp]# cryptsetup close cfile-open
At this point I've filled my encrypted file with 16 MiB of random data. Watch what happens when I open it again using the wrong passphrase and then just to be clear, I'll open it again with the correct one and you'll see the original data is still intact.
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pass"
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 89 97 91 26 b5 46 87 0c 67 87 d8 4a cf 78 e6 d8 |...&.F..g..J.x..|
00000010
[root:tmp]# cryptsetup close cfile-open
[root:tmp]# cryptsetup --key-file - open --type plain cryptfile cfile-open <<<"pa55w0rd"
[root:tmp]# hexdump -n 16 -C /dev/mapper/cfile-open
00000000 00 1d 2d 11 ac 38 c4 d3 cc 81 4f 32 de 64 01 ca |..-..8....O2.d..|
00000010
[root:tmp]#
Enjoy.
| File encryption utility without key integrity check (symmetric key) |
1,518,116,339,000 |
Currently I am using reprepro and inoticoming to maintain a Debian package archive on a remote machine.
The repo is configured with this distributions file:
Origin: ...
Label: ...
Codename: squeeze
Architectures: i386 amd64 armhf source
Components: main
Description: ...
Log: /home/apt/log/reprepro.log
The daemon is running with:
inoticoming \
--logfile /home/apt/log/upload.log \
/home/apt/incoming \
--stdout-to-log \
--stderr-to-log \
--suffix .changes \
reprepro -Vb /home/apt --waitforlock 1000 processincoming default {} \;
I am building and signing my packages locally and then upload with dupload. However when I try to install a package from that archive I get:
WARNING: The following packages cannot be authenticated!
Is there a way to make the signatures work? I absolutely don't want to share my private GPG key with the remote machine. Are there other tools or a better suited workflow?
|
The signatures apt uses are on the repo as a whole (specifically on the "Release" file, not on the individual packages. So they have to be generated as part of the process of adding packages to the repo.
Normally one creates a key specifically for signing the repository with and keeps that on the machine used to manage the repo.
Another option would be to manage the repo locally on your machine and then use a tool like rsync to transfer it to the server.
Another thing that may work would be to Download the release file and create the signature manually after each update to the repo but I haven't tried this myself.
| Keep private key for remote reprepro package archive local |
1,518,116,339,000 |
I am trying to download an update for a piece of software, and my package manager says that the key is invalid and thus warns me.
W: Failed to fetch https://deb.torproject.org/torproject.org/dists/buster/InRelease The following signatures were invalid: EXPKEYSIG 74A941BA219EC810 deb.torproject.org archive signing key
Then the output after listing the key in GPG.
pub rsa2048/0xEE8CBC9E886DDD89 2009-09-04 [SC] [expires: 2022-08-05]
Key fingerprint = A3C4 F0F9 79CA A22C DBA8 F512 EE8C BC9E 886D DD89
uid [ unknown] deb.torproject.org archive signing key
sub rsa2048/0x74A941BA219EC810 2009-09-04 [S] [expires: 2020-11-23]
Key fingerprint = 2265 EB4C B2BF 88D9 00AE 8D1B 74A9 41BA 219E C810
As you can see, the subkey has expired recent to writing this post.
I went to the developer's website and the signing key is unchanged. How do I continue the software update without skipping the signing process?
|
From 2019.www.torproject.org/docs/debian.html.en, you can run these commands to add the key to the trusted apt keys, I only added sudo:
curl https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --import
gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add -
After that sudo apt-key list (or gpg --list-keys) should list the updated key:
pub rsa2048 2009-09-04 [SC] [expires: 2024-11-17]
A3C4 F0F9 79CA A22C DBA8 F512 EE8C BC9E 886D DD89
uid [ unknown] deb.torproject.org archive signing key
sub rsa2048 2009-09-04 [S] [expires: 2022-06-11]
Now you can install the keyring package if you wish to keep the key current:
sudo apt update
sudo apt install deb.torproject.org-keyring
The deb.torproject.org-keyring package contains the current version of the archive signing key (/etc/apt/trusted.gpg.d/deb.torproject.org-keyring.gpg) to validate the authenticity of tor packages.
If you install the package, you'll automatically update the key next time you run sudo apt update; sudo apt upgrade whenever there is an updated version of the key available (assuming the currently installed key is not expired to fetch the package via apt).
| Author's GPG subkey has expired, what can I do? |
1,518,116,339,000 |
To encrypt a file using a person's public key, I can use the following command.
gpg --recipient [email protected] --encrypt --armor file_name
I don't quite understand when this command has multiple --recipient parameters. Below is an example.
gpg --recipient [email protected] --recipient [email protected] --encrypt --armor file_name
This command only generates a single encrypted file called file_name.asc. In this case, does it mean file_name.asc can be decrypted by both user's corresponding private key? Could anyone help to explain when we need multiple --recipient parameters?
|
In this case, does it mean file_name.asc can be decrypted by both user's corresponding private key?
Yes, any of the recipient keys will be able to decrypt the message. Strictly speaking, the message is encrypted using a common key, and that key is encrypted using each provided public key. Thus any of the corresponding private keys can decrypt the common key and then the message.
Could anyone help to explain when we need multiple --recipient parameters?
A common scenario is for email encrypted to multiple recipients. Another is storing encrypted content accessible to multiple users without any shared key.
| What does it mean by gpg encrypting a file with multiple recipients? |
1,518,116,339,000 |
When I apt-get update, the repository for Microsoft's Skype says:
W: An error occurred during the signature verification.
The repository is not updated and the previous index files will be used.
GPG error: https://repo.skype.com/deb stable InRelease: The following signatures were invalid:
EXPKEYSIG 1F3045A5DF7587C3 Skype Linux Client Repository <[email protected]>
W: Failed to fetch https://repo.skype.com/deb/dists/stable/InRelease
The following signatures were invalid:
EXPKEYSIG 1F3045A5DF7587C3 Skype Linux Client Repository <[email protected]>
W: Some index files failed to download. They have been ignored, or old ones used instead.
Why is this happening? Is there something wrong with my system? And what should I do?
|
It seems you need to re-obtain the GPG key, like so:
curl https://repo.skype.com/data/SKYPE-GPG-KEY | sudo apt-key add -
and the warning/error will go away.
See discussion of this issue on the Linux Mint Reddit.
| Skype repository key expired? [duplicate] |
1,518,116,339,000 |
I am playing with gpg verification on some kernel source, and trying to figure out where the gpg configuration file lives. Specifically, when I run --receive-keys, without providing keyserver, what does gpg do?
me@testing:~$ gpg2 -vv --receive-keys 647F28654894E3BD457199BE38DBBDC86092693E
gpg: data source: https://37.191.231.105:443
gpg: armor: BEGIN PGP PUBLIC KEY BLOCK
however this 37.191.231.105 points to analytics.sumptuouscapital.com, and that puzzles me...
btw, I've tried dpkg -L gnupg2 and no .conf file is installed, no .conf file in ~/.gnupg folder either.
|
The upstream default currently uses the SKS keyservers. The IP you saw is one of those listed for hkps.pool.sks-keyservers.net:
$ dig +short hkps.pool.sks-keyservers.net
209.244.105.201
37.191.231.105
192.146.137.98
This is set during compile time via configure.ac:
AC_DEFINE_UNQUOTED(DIRMNGR_DEFAULT_KEYSERVER,
"hkps://hkps.pool.sks-keyservers.net",
[The default keyserver for dirmngr to use, if none is explicitly given])
That will change soon:
gnupg2 (2.2.17-1) unstable; urgency=medium
Upstream GnuPG now defaults to not accepting third-party
certifications from the keyserver network. Given that the SKS
keyserver network is under attack via certificate flooding, and
third-party certifications will not be accepted anyway, we now ship
with the more tightly-constrained and abuse-resistant system
hkps://keys.openpgp.org as the default keyserver.
| What is Debian's default GPG keyserver, and where is it configured? |
1,518,116,339,000 |
I have some RNA-seq files need to be decrypted.
For example
1672_WTSI-OESO_005_w3.tar.gz.gpg
Likely I have key for that in same folder
1672_WTSI-OESO_005_w3.gpgkey
I have also have a file name
1672_WTSI-OESO_005_w3.md5
Inside that I have
884f9fa72fb7f6adbba95dc677eb0ec9 1672_WTSI-OESO_005_w3.tar.gz.gpg
EDITED
[fi1d18@cyan01 fereshteh]$ gpg --decrypt --passphrase-file=1672_WTSI-OESO_036_a_RNA.gpgkey --output - 1672_WTSI-OESO_036_a_RNA.tar.gz.gpg | tar -xvzf -
gpg: CAST5 encrypted data
can't connect to `/home/fi1d18/.gnupg/S.gpg-agent': No such file or directory
gpg: encrypted with 1 passphrase
1672_WTSI-OESO_036_a_RNA/
1672_WTSI-OESO_036_a_RNA/mapped_sample/
1672_WTSI-OESO_036_a_RNA/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-OESO_036_a_RNA.dupmarked.bam.bai
1672_WTSI-OESO_036_a_RNA/mapped_sample/HUMAN_1000Genomes_hs37d5_RNA_seq_WTSI-OESO_036_a_RNA.dupmarked.bam
gpg: WARNING: message was not integrity protected
gzip: stdin: invalid compressed data--crc error
gzip: stdin: invalid compressed data--length error
tar: Skipping to next header
tar: Child returned status 1
tar: Error is not recoverable: exiting now
[fi1d18@cyan01 fereshteh]$
|
The file is, according to the GnuPG output that you show, a file encrypted using the CAST5 algorithm. This is a symmetric encryption algorithm, meaning that you should just be able to use the passphrase in that .gpgkey file with gpg --decrypt to decrypt it (without importing it into your keyring; it's not that kind of key).
To decrypt the file and pass the decrypted data directly to tar for unpacking, you could use
gpg --decrypt --passphrase-file=1672_WTSI-OESO_005_w3.gpgkey --output - 1672_WTSI-OESO_005_w3.tar.gz.gpg |
tar -xvzf -
This would read the key from the provided file, decrypt the message using that key, and pass the data on to tar.
If the file 1672_WTSI-OESO_005_w3.gpgkey does not decrypt the message, then you will have to get in touch with whoever provided you with the encrypted file and ask them for instructions about how to decrypt it.
The .md5 file is used to ensure that the .gpg file contains the correct data. You can use it to verify the data like this:
md5sum -c 1672_WTSI-OESO_005_w3.md5
If this does not give the output
1672_WTSI-OESO_005_w3.tar.gz.gpg: OK
then the file is corrupt somehow, and you need a fresh copy of it from wherever you got it. If it says FAILED, then gpg and tar will not be able to decrypt and unpack the data.
The error shown at the end of the updated question (now deleted) is Cannot write: Disk quota exceeded. This means that the files extracted from the archive are too big to fit in the space allotted to your account.
To fix this, either delete or compress files no longer needed, until you have enough space to extract the archive, or talk with your system administrator(s) and have them allocate more disk space to your account.
| Decrypting GnuPG-encrypted files |
1,518,116,339,000 |
I am trying to install Hexinator on Linux
sudo apt-key adv --keyserver keys.gnupg.net --recv-keys A04A6C4681484CF1
Executing: /tmp/tmp.jHAVvyUasz/gpg.1.sh --keyserver
keys.gnupg.net
--recv-keys
A04A6C4681484CF1
gpg: requesting key 81484CF1 from hkp server keys.gnupg.net
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
What should I try?I am on Ubuntu 16.04.How to check if firewall is blocking the port?
|
You are probably behind a firewall.
Try this:
sudo apt-key adv --keyserver hkp://keys.gnupg.net:80 --recv-keys A04A6C4681484CF1
It worked for me (I'm behind a firewall. The original one didn't work).
| gpg: keyserver receive failed: keyserver error |
1,518,116,339,000 |
So far while surfing web I've discovered nice addition to my gpg password generator and I've decided to adjust my alias with these commands.
Here is the code
gpg --gen-random 1 20 | perl -ne'print "Your password: ";s/[\x00-\x20]/chr(ord($^N)+50)/ge;s/([\x7E-\xDB])/chr(ord($^N)-93)/ge;s/([\xDC-\xFF])/chr(ord($^N)-129)/ge;print $_, "\n"'
Here is what I've tried so far:
alias genpass()
{
gpg --gen-random 1 $1 | perl -ne'
print "Your password: ";
s/[\x00-\x20]/chr(ord($^N)+50)/ge;
s/([\x7E-\xDB])/chr(ord($^N)-93)/ge;
s/([\xDC-\xFF])/chr(ord($^N)-129)/ge;
print $_, "\n"'
}
but error occurs when spawning new instance of bash:
bash: /home/user/.bashrc: line 18: syntax error near unexpected token `('
bash: /home/user/.bashrc: line 18: `alias genpass()'
I cannot figure out how this token should be properly escaped.
|
You have the alias statement when you don't need it, what you're actually creating is a function, replace the word alias with function and it will work as expected.
You also don't actually need function either, you could just have the following and it will work as expected;
genpass()
{
gpg --gen-random 1 $1 | perl -ne'
print "Your password: ";
s/[\x00-\x20]/chr(ord($^N)+50)/ge;
s/([\x7E-\xDB])/chr(ord($^N)-93)/ge;
s/([\xDC-\xFF])/chr(ord($^N)-129)/ge;
print $_, "\n"'
}
| Alias for perl script |
1,518,116,339,000 |
Here on a Debian system I use mainly gpg2. Some (Debian packaging/signing) tools use gpg1 internally, and changing them as it should be would be infeasible.
Both my gpg versions are using the same work directory (~/.gnupg) and their databases / configuration seem mainly compatible. An exception for this is the handling of the private keys.
As I experienced, private keys created by gpg2 are not visible for gpg1 (but their public pairs are).
Digging a lot on the net, as I understand, the gpg versions are using different files (and maybe different formats) below ~/.gnupg to store them. There are also various one-line solutions to convert the gpg2 database to gpg1 and vice versa.
Now I have to use mainly gpg2, but I have to allow also gpg1 to work. My idea for this task is that
I export the gpg2 private key database.
I import it with gpg1.
The expected result would be that I can see the same public and private keys with both gpg versions.
Is it possible? Could it work? How can I do that?
(Note: at least Ubuntu and Mint uses already gpg2 for packaging tasks, but Debian still doesn't.)
|
GnuPG 1.4, 2.0 and 2.1 all support the "good old" pubring.gpg file for storing public keys. As long as a pubkey.gpg exists, also GnuPG 2.1 will continue to use it and not create a public keyring in the new keybox format.
There are differences with respect to private keys, though. While GnuPG 1.4 and 2.0 both store private keys in the secring.gpg file, GnuPG 2.1 merges those into the public keyring file, such that GnuPG 2.1 (gpg2, on newer distributions also gpg) and GnuPG 1.4 (gpg1 if available, on older distributions also gpg) do not share a common secret keyring store any more (but still can do for the public keyring, as already explained).
If you export the secret keys from gpg2 and import them to gpg/gpg1, you should be able to use them from both implementations. GnuPG 1.4 does not mind that secret keys are stored in your pubring.gpg file. Be aware GnuPG 1.4 cannot merge secret key packets; if you change your subkeys in GnupG 2.1 and want to copy them to GnuPG 1.4 agein, you will have to delete the secret key from GnuPG 2.1 and import it again. Always make a backup copy before changing anything!
| Can I use GnuPG 2 and GnuPG 1 concurrently, seeing the same keys? |
1,518,116,339,000 |
I wish to do something like:
echo -e "trust\n5" | gpg --edit-key "Dor"
In order to supply GPG with answers that were made in advance.
But it doesn't work. Any idea?
|
echo -e "trust\n5" | gpg --edit-key "Dor" doesn't work because gpg does not read the answers from stdin, but opens /dev/tty directly for reading.
This can be worked around with expect, a tool for automating interactive applications.
| Feed GPG with answers |
1,518,116,339,000 |
Like under an average Linux distribution - are there any checkings that the downloaded packages are really the packages that are on the mirror server?
|
Packages fetched by pkg_add from the official mirror sites are signed and the pkg_add utility will automatically check the signatures against the keys available on your system.
From the pkg_add manual:
If a package is digitally signed:
• pkg_add checks that its signature is valid and that the signature was
emitted by a valid signing key, as stored in /etc/signify/*-pkg.pub,
• pkg_add verifies that the compressed package data matches the
signature, before it decompresses and unpacks files.
The signatures are not checked using GnuPG but with the native signify utility.
Old (outdated) answer from 2011:
No, there are not. But see these threads from the openbsd-misc list:
package integrity, security and checks. .... where are they ?
package and port paranoia
| Are there any GPG checks in OpenBSD when installing an application? |
1,518,116,339,000 |
The problem
UPDATE: Currently investigating with strace. It seems problem is a HTTP 400 error when accessing the repository
UPDATE2: More weird errors in the server (a .so lib file corrupted, database engine displaying 'Unknown error') so it seems this problem is due to a hardware error.
Unknown error executing apt-key
For example, an fragment of a apt update execution:
[...]
Get:3 http://deb.debian.org/debian buster-updates InRelease [56,6 kB]
[...]
Err:3 http://deb.debian.org/debian buster-updates InRelease
Unknown error executing apt-key
[...]
W: GPG error: http://deb.debian.org/debian buster-updates InRelease: Unknown error executing apt-key
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed.
[...]
This was working perfectly since long ago and started to happen overnight. Nothing special was done to the server.
I have other servers with almost the same configuration and they are working ok.
I see no relevant entries in apt and system logs.
What I've tried
There are some posts that say I've to delete /var/lib/apt, check the trusted keys and similar approaches. None worked.
I've checked the output of apt-key list: the list is almost the same as another server that works ok, the other server just has one more key for the Jenkins repository.
The output is something like this:
/etc/apt/trusted.gpg.d/debian-archive-bullseye-security-automatic.gpg
---------------------------------------------------------------------
pub rsa4096 2021-01-17 [SC] [expires: 2029-01-15]
AC53 0D52 0F2F 3269 F5E9 8313 A484 4904 4AAD 5C5D
uid [ unknown] Debian Security Archive Automatic Signing Key (11/bullseye) <[email protected]>
sub rsa4096 2021-01-17 [S] [expires: 2029-01-15]
/etc/apt/trusted.gpg.d/debian-archive-bullseye-stable.gpg
---------------------------------------------------------
pub rsa4096 2021-02-13 [SC] [expires: 2029-02-11]
A428 5295 FC7B 1A81 6000 62A9 605C 66F0 0D6C 9793
uid [ unknown] Debian Stable Release Key (11/bullseye) <[email protected]>
/etc/apt/trusted.gpg.d/debian-archive-buster-automatic.gpg
----------------------------------------------------------
pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12]
80D1 5823 B7FD 1561 F9F7 BCDD DC30 D7C2 3CBB ABEE
uid [ unknown] Debian Archive Automatic Signing Key (10/buster) <[email protected]>
sub rsa4096 2019-04-14 [S] [expires: 2027-04-12]
/etc/apt/trusted.gpg.d/debian-archive-buster-security-automatic.gpg
-------------------------------------------------------------------
pub rsa4096 2019-04-14 [SC] [expires: 2027-04-12]
5E61 B217 265D A980 7A23 C5FF 4DFA B270 CAA9 6DFA
uid [ unknown] Debian Security Archive Automatic Signing Key (10/buster) <[email protected]>
sub rsa4096 2019-04-14 [S] [expires: 2027-04-12]
Because I have other servers with almost the same configuration (same Debian 10 OS, very similar installed packages, etc) I desperately tried copying their /var/lib/apt and /ec/apt folders to this faulty server: the error persists.
Because I suspect GPG could be wrong, I tried to reinstall it. I downloaded the package from Debian repository and installed using dpkg: same result, issue persists.
Enabling apt debugging: what is different from a working server
You can enable apt debugging. In my case I use:
apt -o Debug::Acquire::http=false -o Debug::Hashes=true -o Debug::pkgAcquire::Auth=true -o Debug::sourceList=true update
This is interesting. I've commented all sources but deb http://deb.debian.org/debian buster main contrib non-free. The faulty server yields:
# apt -o Debug::Acquire::http=false -o Debug::Hashes=true -o Debug::pkgAcquire::Auth=true -o Debug::sourceList=true update
Get:1 http://deb.debian.org/debian buster InRelease [122 kB]
201 URI Done: http://deb.debian.org/debian/dists/buster/InRelease
ReceivedHash:
- SHA512:c65abc258e9ecc7e506133502add58d9c451bc11c3dd9bf7f23a0d58fb0f7747cc75bee22e58dece5af63f6a1cc7dd7c150a383fbd79ce23655c7aca6c32b78c
- SHA256:45420bba913bb4d35b98319d893d9db2bc0c4034a12c65f07118dd36ee4cea86
- SHA1:dcbc9207da6730f5a268f7c8f452ad62f0fd9705
- MD5Sum:2f497e0885083bf377d7f5cafe9b1762
- Checksum-FileSize:121570
ExpectedHash:
Err:1 http://deb.debian.org/debian buster InRelease
Unknown error executing apt-key
Reading package lists... Done
W: GPG error: http://deb.debian.org/debian buster InRelease: Unknown error executing apt-key
E: The repository 'http://deb.debian.org/debian buster InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
However, the working servers outputs:
# apt -o Debug::Acquire::http=false -o Debug::Hashes=true -o Debug::pkgAcquire::Auth=true -o Debug::sourceList=true update
0% [Working]201 URI Done: http://deb.debian.org/debian/dists/buster/InRelease
ReceivedHash:
ExpectedHash:
Hit:1 http://deb.debian.org/debian buster InRelease
0% [Working]201 URI Done: http://deb.debian.org/debian/dists/buster/InRelease
ReceivedHash:
ExpectedHash:
Signature verification succeeded: /var/lib/apt/lists/deb.debian.org_debian_dists_buster_InRelease
Got Codename: buster
Got Suite: oldstable
Expecting Dist: buster
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
As you can see, the faulty server seems to receive some hashes and has no expected hash while the working sever has no hashes at all?
What about other sources? If I try with deb http://deb.debian.org/debian buster-updates main contrib non-free, the fault servers outputs:
# apt -o Debug::Acquire::http=false -o Debug::Hashes=true -o Debug::pkgAcquire::Auth=true -o Debug::sourceList=true update
Get:1 http://deb.debian.org/debian buster-updates InRelease [56,6 kB]
0% [1 InRelease 56,6 kB/56,6 kB 100%]201 URI Done: http://deb.debian.org/debian/dists/buster-updates/InRelease
ReceivedHash:
- SHA512:3542a4de41bdffba0631f27efdf2dd69602b77b1dd7362285527d3e96d22daaae1165979fc83a740049e2c54de455f798c07f0120baeafd316dd2e9efd68faab
- SHA256:65d8f69e329505a4abdc3968778e36adae20b8542eed9745c60c47bc90ea4c05
- SHA1:e901931cf25b06819fe1a653b39621b5e42a0109
- MD5Sum:db7403e0f919a66b1e05ed537962d333
- Checksum-FileSize:56621
ExpectedHash:
Err:1 http://deb.debian.org/debian buster-updates InRelease
Unknown error executing apt-key
Reading package lists... Done
W: GPG error: http://deb.debian.org/debian buster-updates InRelease: Unknown error executing apt-key
E: The repository 'http://deb.debian.org/debian buster-updates InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
More or less the same error than before. It includes several keys in ReceivedHash but empty value in ExpectedHash.
What about the working server? It outputs:
# apt -o Debug::Acquire::http=false -o Debug::Hashes=true -o Debug::pkgAcquire::Auth=true -o Debug::sourceList=true update
Get:1 http://deb.debian.org/debian buster-updates InRelease [56,6 kB]
0% [1 InRelease 16,4 kB/56,6 kB 29%]201 URI Done: http://deb.debian.org/debian/dists/buster-updates/InRelease
ReceivedHash:
- SHA512:3542a4de41bdffba0631f27efdf2dd69602b77b1dd7362285527d3e96d22daaae1165979fc83a740049e2c54de455f798c07f0120baeafd316dd2e9efd68faab
- SHA256:65d8f69e329505a4abdc3968778e36adae20b8542eed9745c60c47bc90ea4c05
- SHA1:e901931cf25b06819fe1a653b39621b5e42a0109
- MD5Sum:db7403e0f919a66b1e05ed537962d333
- Checksum-FileSize:56621
ExpectedHash:
0% [Working]201 URI Done: http://deb.debian.org/debian/dists/buster-updates/InRelease
ReceivedHash:
ExpectedHash:
Signature verification succeeded: /var/lib/apt/lists/partial/deb.debian.org_debian_dists_buster-updates_InRelease
....and lot of other lines about other files it downloads, but I guess they are not interesting for this issue.
In this case, the working server also receives hashes in ReceivedHash and empty value in ExpectedHash.
Error 400 accessing repository
Ok, let's dig more into this. Let's use strace. This is the interesting part:
lchown("/var/lib/apt/lists/partial/deb.debian.org_debian_dists_buster-updates_InRelease", 100, 0) = 0
lstat("/var/lib/apt/lists/partial/deb.debian.org_debian_dists_buster-updates_InRelease", {st_mode=S_IFREG|0644, st_size=56621, ...}) = 0
chmod("/var/lib/apt/lists/partial/deb.debian.org_debian_dists_buster-updates_InRelease", 0600) = 0
rt_sigprocmask(SIG_BLOCK, [WINCH], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
0% [Working]) = 18% [Working]", 18
write(1, "\33[0m", 4) = 4
select(11, [5 6], [10], NULL, {tv_sec=0, tv_usec=500000}) = 1 (out [10], left {tv_sec=0, tv_usec=499997})
write(10, "601 Configuration\nConfig-Item: A"..., 11121) = 11121
select(7, [5 6], [], NULL, {tv_sec=0, tv_usec=499997}) = 1 (in [6], left {tv_sec=0, tv_usec=364398})
read(6, "400 URI Failure\nMessage: Unknown"..., 64000) = 148
stat("/var/lib/apt/lists/partial/deb.debian.org_debian_dists_buster-updates_InRelease", {st_mode=S_IFREG|0600, st_size=56621, ...}) = 0
getuid() = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 7
connect(7, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
sendto(7, "\2\0\0\0\0\0\0\0\5\0\0\0root\0", 17, MSG_NOSIGNAL, NULL, 0) = 17
poll([{fd=7, events=POLLIN|POLLERR|POLLHUP}], 1, 5000) = 1 ([{fd=7, revents=POLLIN}])
Specifically, this line:
read(6, "400 URI Failure\nMessage: Unknown"..., 64000) = 148
It seems there's an error during transfer.
What to do now?
How I can dig more into the HTTP error? Can I use apt-key to mimic the request that returns 400? What could I do to fix this (apart form ignoring the GPG sign checks)? Or what other checks can I do to locate the root cause of the issue?
|
After a reboot with a rescue disk I used fsck to check the EXT4 filesystem: there were hundreds of errors.
Then, I reinstalled every installed packaged to fix any corrupt binary file.
After this, the apt error is gone. It was due to a corrupted file related to some package used by apt.
UPDATE
SSD was dying ad finally I had to switch to another server. Backups worked, no data was harmed during this incident.
| Suddenly a server refuses to 'apt update' because an 'Unknown error executing apt-key' |
1,518,116,339,000 |
I have searched the whole universe this error but i could not find any helpful tips.
I have created a key using keybase and added my public key to github gpg
my gpg --list-secret-keys --keyid-format LONG
is this
--------------------------------
sec rsa4096/7E8*******60B47B 2021-03-06 [SC] [expires: 2037-03-02]
51FBCD0E******************014D4860B47B
uid [ultimate] Fatih <********@live.be>
uid [ultimate] Fatih <[email protected]>
ssb rsa4096/15BBF8A123C4AC1B 2021-03-06 [E] [expires: 2037-03-02]
my .gitconfig is this
[user]
signingkey = 7E8*******60B47B
email = [email protected]
name = kgnfth
[commit]
gpgsign = true
[gpg]
program = gpg
i added export GPG_TTY=$(tty) to my .zshrc file
Everytime i run git commit -m "first commit",
i get this error
error: gpg failed to sign the data
fatal: failed to write commit object
I dont see anything wrong with the signing key
i also tried changing gpg to gpg2 but the same error appears
i am out of idea
i need your help
Thank you.
|
i resolved my issue by adding gpg-agent plugin to my zshrc config file.
| gpg failed to sign the data, failed to write commit object |
1,518,116,339,000 |
Is it good/common practice to store the gpg private keys on my local machine, even if
I intend to use them for pass, which obviously encrypts sensible data.
Is there a sensible alternative, like storing it on a usb stick?
I am on a Debian Buster Machine.
Edit: Please tell me if this question is misplaced here. I will remove it immediately
|
Common practice ? Definitely.
Good practice ? It depends on your threat model and how sensitive the data you are trying to protect is.
I for example like to use PGP with smart cards and use a reader with a PINpad. Thus, a keylogger cannot steal the passphrase. If the computer is stolen, the subkeys are not stored locally. Then the risk of compromise of my PGP keys is low.
I also make sure to generate the keys on an airgapped computer with no network access and running a live distro like Tails, and I transfer them to the smart card immediately.
To sum up there are two things you need to protect: the private keys and the passphrase. A trojan installed on your machine can potentially obtain both.
Say your keys are stored on a laptop and it gets stolen. Assuming your laptop does not have an encrypted, disk, BIOS password or some kind of obstacle, the thief can gain access to the private keys but does not have the passphrase, although a brute-force attack is possible in theory.
Of course you can protect the laptop better, for example encrypt your partition with luks or another scheme, using a strong password that cannot be guessed easily. Then you make it difficult or downright impossible for the thief to compromise your secrets.
Yes, PGP keys should be well protected but good computer security hygiene does not stop there.
| Keeping GPG Private Keys on Local machine? |
1,518,116,339,000 |
I just installed Kali NetHunter and I'm trying to do a simple apt update but it looks like a public key is missing
root@kali:~# apt-get update
0% [Waiting for headers] [Connected to packages.microsoft.com (13.8Get:2 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease [3232 B]
Hit:1 http://kali.download/kali kali-rolling InRelease
Err:2 https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
Reading package lists... Done
W: GPG error: https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/repos/microsoft-debian-stretch-prod stretch InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
I tried
curl -s https://packages.microsoft.com/repos/microsoft-debian-stretch-prod/dists/stretch/Release.gpg | apt-key add -
and
wget --no-check-certificate https://packages.microsoft.com/repos/microsoft-debian-stretch-prod/dists/stretch/Release.gpg | apt-key add -
And the result was gpg: no valid OpenPGP data found for both
|
The workaround solution I found is to delete /etc/apt/sources.list.d/microsoft.list and to make sure the kali repo is uncommented and is inside the main /etc/apt/sources.list
| GPG error when I want to apt update |
1,518,116,339,000 |
There is an option named default-cache-ttl that controls how long the agent will remember the password to the private key. However, when I put it in the config file it doesn't work - instead, gpg complains:
gpg: /home/jan/.gnupg/gpg.conf:8: invalid option
My version of GPG is
$ gpg2 --version
gpg (GnuPG) 2.1.11
|
Wrong config file. This option concerns gpg-agent only, and (somewhat surprisingly) it has a separate configuration file - .gnupg/gpg-agent.conf. Put the option there and it works (configuration for GPG 2.1, earlier versions use different option names):
$ cat .gnupg/gpg-agent.conf
# remember the password longer (1 hour since last usage, 5 hours max)
default-cache-ttl 3600
max-cache-ttl 18000
| GPG cache options don't work |
1,518,116,339,000 |
I have the following problem. I'm currently need to store my backup on a cloud solution like dropbox since my local nas is broken. That's why I have to encrypt my backup. I'm using rsnapshot to generate it.
On the NAS I didn't encrypt it so I'm not experienced with it. What I've done is, I've zipped the latest backup and simple encrypted it via gpg. However, its still encrypting. My backup is aronud 50GB. I've never encrypted such a big file. Is there a way to encrypt such big files more efficiently or what am I doing wrong?
|
The time it takes to encrypt is proportional to the size of the data, plus some constant overhead. You can't save time for the whole operation by splitting the data, except by taking advantage of multiple cores so that it takes the same CPU time overall (or very slightly little more) but less wall-clock time. Splitting can of course be advantageous if you later want to access part of the data.
GnuPG compresses data before encrypting it. If the data is already compressed, this won't do anything useful and may slow the process down a little.
I recommend duplicity to make encrypted backups. It takes care of both collecting files and calling GPG and it knows how to do incremental backups. It splits the data into multiple volumes, so it can save wall-clock time by encrypting one volume while it's collecting files for the next one.
The first time you back up 50GB is going to be slow regardless. If you have AES acceleration on your hardware, it helps (as long as you make sure that GPG is using AES — GnuPG used CAST-5 by default before version 2.1, but it uses your public key's preferences and that should default to AES even in GPG 1.4 or 2.0).
| how to efficiently encrypt backup via gpg |
1,518,116,339,000 |
We host some of our own software packages as debs in a repository of our own. For prototyping purposes, we’ve been running “unauthenticated”. Now we're trying to do things more correctly and do the whole GPG thing. What I’ve tried, just for test run is the following:
1) Make a key with gpg-gen
~$ gpg --list-keys
/home/me/.gnupg/pubring.gpg
--------------------------------
pub 4096R/BBBBB39F 2017-03-09
uid Someone Somebody <[email protected]>
sub 4096R/129E9336 2017-03-09
(what btw, is the SUB thing there?)
2) aptly publish... This prompts me for my passphrase for said key, so it must be doing something with the key at that point.
3) export the key using gpg —export —armor > somefile.pubkey
4) copy some file.pubkey over to a test machine
5) run sudo apt-key add somefile.pubkey
sudo apt-key list
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2017-03-09 [SC]
E51B E216 4658 FB8B 6E42 8A09 F9BC EF4C BBBB B39F
uid [ unknown] Someone Somebody <[email protected]>
sub rsa4096 2017-03-09 [E]
…
…
…
So, it seems to have gotten in there. The sub thing shows up differently now?
6) And finally, sudo apt-get update:
~$ sudo apt-get update
Hit:1 http://ftp.us.debian.org/debian stretch InRelease
Hit:2 http://ftp.us.debian.org/debian stretch-updates InRelease
Hit:3 http://security.debian.org stretch/updates InRelease
Get:4 http://our.aptly.repo stretch InRelease [2317 B]
Ign:4 http://our.aptly.repo stretch InRelease
Fetched 2317 B in 9s (256 B/s)
Reading package lists... Done
W: GPG error: http://our.aptly.repo stretch InRelease: The following signatures were invalid: E51BE2164658FB8B6E428A09F9BCEF4CBBBBB39F
W: The repository 'http://our.aptly.repo stretch InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
I don’t understand what’s happening here. The offense seems to be that something is not signed? What step did I miss?
|
An up-to-date Debian stretch install no longer accepts SHA1 signatures. However, Aptly used SHA1 until v0.9.7 (relevant PR, note that it was also backported to v0.9.6.1). I suspect the version of Aptly you're using is older than that. If so, consider adding their repo to your sources.list.
| Frustrated with aptly and GPG signing |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.