diff --git a/examples/ssh/ssh_config b/examples/ssh/ssh_config index 0a48f0f..f22475d 100644 --- a/examples/ssh/ssh_config +++ b/examples/ssh/ssh_config @@ -86,3 +86,6 @@ HashKnownHosts no ServerAliveCountMax 2 ServerAliveInterval 300 UseKeyChain yes + +# GnuPG integration +IdentityAgent ~/.gnupg/S.gpg-agent.ssh diff --git a/knowledge base/gnupg.md b/knowledge base/gnupg.md index a8324e8..0e53cf7 100644 --- a/knowledge base/gnupg.md +++ b/knowledge base/gnupg.md @@ -379,10 +379,11 @@ Now tell SSH how to access `gpg-agent` by setting the value of the `SSH_AUTH_SOC Alternatively, and for a more permanent solution, set the option in the `.ssh/config` file: ```sh -export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) +export SSH_AUTH_SOCK=$(gpgconf --list-dirs 'agent-ssh-socket') # alternative -echo "IdentityAgent $(gpgconf --list-dirs agent-ssh-socket)" >> ~'/.ssh/config' +echo "\nIdentityAgent $(gpgconf --list-dirs 'agent-ssh-socket')" \ +| tee -a ~'/.ssh/config' ``` Now you can launch the gpg agent: diff --git a/knowledge base/ssh.md b/knowledge base/ssh.md index b5b295b..c7f3eec 100644 --- a/knowledge base/ssh.md +++ b/knowledge base/ssh.md @@ -8,6 +8,7 @@ 1. [Client configuration](#client-configuration) 1. [Append domains to a hostname before attempting to check if they exist](#append-domains-to-a-hostname-before-attempting-to-check-if-they-exist) 1. [Optimize connection handling](#optimize-connection-handling) + 1. [Integrate with GnuPG](#integrate-with-gnupg) 1. [Server configuration](#server-configuration) 1. [Change port](#change-port) 1. [Disable password authentication](#disable-password-authentication) @@ -229,6 +230,22 @@ ControlPath ~/.ssh/control-%C ControlPersist 30s ``` +### Integrate with GnuPG + +```sh +# In BASH and alike. +export SSH_AUTH_SOCK=$(gpgconf --list-dirs 'agent-ssh-socket') + +# In FISH. +set -x 'SSH_AUTH_SOCK' (gpgconf --list-dirs 'agent-ssh-socket') +``` + +```ssh-config +# In ~/.ssh/config. +# Value is from `gpgconf --list-dirs 'agent-ssh-socket'`. +IdentityAgent ~/.gnupg/S.gpg-agent.ssh +``` + ## Server configuration Config file defaults to `/etc/ssh/sshd_config`.