From 5e936b7e9a8c272d6cc4c03167bfdded7aeca9f9 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sat, 3 Feb 2024 19:50:22 +0100 Subject: [PATCH] chore: improved the section for ssh integration --- knowledge base/gnupg.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/knowledge base/gnupg.md b/knowledge base/gnupg.md index cef07db..43ec761 100644 --- a/knowledge base/gnupg.md +++ b/knowledge base/gnupg.md @@ -90,6 +90,9 @@ brew install 'gnupg' export SSH_AUTH_SOCK="$(gpgconf --list-dirs 'agent-ssh-socket')" && \ gpgconf --launch 'gpg-agent' +# Export the SSH public key for identities. +gpg --export-ssh-key 'identifier' + # Integrate with Pinentry. export GPG_TTY="$(tty)" ``` @@ -324,7 +327,7 @@ ssb rsa2048 2019-03-21 [E] [expires: 2021-03-20] ssb rsa2048 2019-03-21 [A] Keygrip = 7710BA0643CC022B92544181FF2EAC2A290CDC0E -$ echo 7710BA0643CC022B92544181FF2EAC2A290CDC0E >> ~/.gnupg/sshcontrol +$ echo 7710BA0643CC022B92544181FF2EAC2A290CDC0E >> ~'/.gnupg/sshcontrol' ``` Now tell SSH how to access `gpg-agent` by setting the value of the `SSH_AUTH_SOCK` environment variable. @@ -334,6 +337,15 @@ export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) gpgconf --launch gpg-agent ``` +Check the key has been imported correctly: + +```sh +$ gpg --export-ssh-key 'Brian Exelbierd' +ssh-rsa AAAAB3NzaC…7SD8UQ== openpgp:0x7BB65DA2 +$ ssh-add -L +ssh-rsa AAAAB3NzaC…7SD8UQ== (none) +``` + ### Share the GPG-SSH key Run `ssh-add -L` to list your public keys and copy them over manually to the remote host, or use `ssh-copy-id` as you would normally do.