gpgconf --launch gpg-agent
Save the bashrc file, then print the subkey's keygrip:
gpg --list-keys --with-keygrip
Copy the subkey's keygrip, then create the file 'sshcontrol' in the .gnupg directory :
nano ~/.gnupg/sshcontrol
Paste your identity keygrip into the new file, then save it.
Apply the new SSH and GPG configuration by reloading the bashrc file on the current terminal session:
source ~/.bashrc
Check if the SSH daemon is currently working properly by listing its SSH public key:
ssh-add -l
At this point, you should have the SSH daemon correctly linked to your GPG agent. To use it, generate an SSH export key with the following command:
gpg --ssh-export-key YOUR-KEY@EMAIL.ADDRESS > ~/authorized_keys
Set the export key's permission bits to be readable and writable only by the user:
chmod 600 ~/authorized_keys
Send new authorization file to remote server using scp:
scp ~/authorized_keys YOUR-REMOTE.SERVER.DOMAIN:~/.ssh/authorized_keys
Log in to the remote server, then restart the SSH daemon to apply the new key:
sudo systemctl restart ssh.service
Press Ctrl + D , then log back into the remote SSH server. This will bring up a new prompt asking to enter the master GPG key password.
Binding a GPG key to the SSH daemon and exporting it to a remote server are just some of the things you can do with SSH. Discover what can be done with this amazing software using SSH with UNIX pipes in Linux.