Convert GPG key to ssh key

Werner Koch wk at
Mon Dec 8 18:18:52 CET 2014

On Mon,  8 Dec 2014 17:05, kardan38 at said:

> I am just trying to convert gpg key to ssh key to be able use it in
> authorized_keys file and I am using *`gpgkey2ssh $key_id`  *command.

No need to convert a key if you are using gnupg 2.1.  Run 

  gpg -K --with-keygrip USERID

and pick the keygrip from the output.  For example:

  sec#  rsa2048/E455F2D7CC9C6BBC 2009-11-05
        Keygrip = B0C352EC5B3336681535ED3CC2FA62807B64B2CF
  uid               [ unknown] Enoch Root (test) <enoch at>
  ssb   rsa2048/591B5112D5A9C5A6 2009-11-05
        Keygrip = 84722EE009690AA87BAF80A62EB0186CFCF72E64
  ssb#  rsa2048/D367147F5CB0CDF0 2009-11-05
        Keygrip = 79DA43AD276B52EABFF0661153276A8E5A5F8DB9

To use the second subkey with ssh, you then do:

  echo >>~/.gnupg/sshcontrol 79DA43AD276B52EABFF0661153276A8E5A5F8DB9  0

(note the "0" after the keygrip)



Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.

More information about the Gnupg-users mailing list