GPG Keychain not showing key from Smart Card

GnuPG stores only the secret key(s) on the smart card. The public key and the user IDs are not the the card.
The result of this is, that you can't simply use "--card-status" to get the card to work.
First you need the public key in your keychain. This is the case, when you generate a new key.

Now i will describe the correct way to handle this:

  1. Generate a new key on the card or move an existing to the card:

    • Generate a new key: "gpg2 --card-edit" and "generate" OR
    • Move an existing key: "gpg2 --edit-key 00D026C4" and "keytocard".
  2. Upload the key to a key server:

    gpg2 --keyserver hkps:// --send-keys 00D026C4
  3. Set the URL, to retrieve the public key, on the card.

    gpg2 --card-edit

Replace every occurrence of "00D026C4" in the commands, with the ID of your key!

Steps to use the smart card on a (new) computer:

  1. Get the public key (only if the public key isn't already in your keychain)

    gpg2 --card-edit
  2. Create a stub for the secret key in your keychain

    gpg2 --card-status
  3. Use the (secret) key as if it was in your keychain