How to import an SSH ed25519 key to GPG?
I have an SSH ed25519 key which I would like to import to GPG as an Authentication Subkey. There doesn't appear to be any documentation available on how to do this.
Solution 1:
The first step is impossible.
But you can import SSH ed25519 private key to GPG.
Assume that you have already setup gpg-agent
.
- Setup
SSH_AUTH_SOCK
andGPG_TTY
environment variables byexport SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
andexport GPG_TTY=$(tty)
. - Add your SSH private key to GPG by
ssh-add ed25519-filename
.
Note that if you are asked for a new password, it is recommended that you use the same as your GPG master password. - Identify the keygrip of the private key that you added by step 2.
- Check the keygrips of your existing GPG private keys by
gpg -K --with-keygrip
. - Check private key files by
ls -l $(gpgconf --list-dirs homedir)/private-keys-v1.d
. - The filename of step 3-2 that is not in the keygrips of step 3-1 is the keygrip that you added by step 2.
- Check the keygrips of your existing GPG private keys by
- Setup the key added by
ssh-add
to a subkey.- Start GPG by `gpg --expert -edit-key "Your-existing-GPG-Key-ID".
- Enter
addkey
command. - Select "Existing key". (Maybe "13")
- Enter the keygrip identified by step 3.
- Set the capability as you wish and Finish.
- Then, answer the questions appropriately.
Note that you should answerY
toReally create?
andSave changes?
etc.
- Verify that the import was successful by
gpg -K --with-keygrip
.
You should be able to see the keygrip that you just added.