~dbalan/blogng unlisted

9ceed4ccb29f0aa025251542a61d6caef0f7420c — Dhananjay Balan 9 months ago 643c31f
Intial, bad picture
1 files changed, 51 insertions(+), 0 deletions(-)

A blog/2019-10-30-one-key-to-rule-them-all.markdown
A blog/2019-10-30-one-key-to-rule-them-all.markdown => blog/2019-10-30-one-key-to-rule-them-all.markdown +51 -0
@@ 0,0 1,51 @@
layout: post
title: "One key to rule them all!"
date: 2019-10-30
comments: true
tags: gnupg, nitrokey, security

_"alternatively, how I use Nitrokeys/GnuK/YubiKeys"_

Most popular use for [NitroKeys](https://www.nitrokey.com/) seems to be as a **2FA** [FIDO](https://en.wikipedia.org/wiki/Universal_2nd_Factor) key. Most of these devices can also behave (_emulate_ technically speaking) as an OpenPGP smartcard[^gpgsupport] to store your gpg keys.

![one of my smartcards along with the nice "Where the wild things are" library card](https://vault.thaum.space/apps/files_sharing/publicpreview/wNtSPtfKkrPMGsr?x=1910&y=501&a=true&file=19-10-30%252009-55-36%25203280.jpg&scalingup=0)

## Why should you use a smartcard?

### 1. Security

GnuPG keys stored on smartcards only allow narrow access. Smartcards exposes APIs to perform specific PGP operations like _sign_, _encrypt_, _verify signature_ etc and no more as opposed to keys stored on local disk which gives all out access to keys if one has access to disk. Most important access that smartcards deny is the ability to copy them; essentially tieing your key to a physical object that can't be replicated. As long as you know where your physical key is, none else has access to them (at that point).

Almost __all of the software__ we run has access to users disk on most operating systems and we have seen exploits that target keys stored on disk [again](https://www.mozilla.org/en-US/security/advisories/mfsa2015-78/) and [again](https://en.wikipedia.org/wiki/Careto_(malware)). The keys stored on disk are often encrypted, but stealing your key password just the matter of chaining another exploit.

### 2. Compossibility[
Having a physical root of trust combined with the fact that a lot of software supports GnuPG makes this a really nice composable component in my daily life.

Some work-flows that I use daily:

#### SSH support
GnuPG has native support for SSH. Your smartcard becomes my ssh key as well and I can roam between my multiple machines without actually having to copy and leave keys around or having to manage multiple keys. 

I also use a similar key for github.

#### Pass password manager
[pass](https://www.passwordstore.org/) is a password manager following UNIX philosophy. It uses GnuPG keys to encrypt passwords, and by using a key on the smartcard, you can tie the trust to the smartcard.

Pass also opens up a lot more composable behaviors, I use it mostly for the next one --

#### AWS Vault
[aws-vault](https://github.com/99designs/aws-vault) is a nifty tool to manage AWS credentials. It can transparently issue temporary keys and populate shell environment.

I am not going to cover setting up the card here, since there are a lot of documentation about how to do so, and it varies slightly by the card that one is using. However I'd suggest to not generate keys on the card card it self, since you have zero backups in case you loose the card and also, we have seen [it is really hard to generate good keys on small devices](https://en.wikipedia.org/wiki/ROCA_vulnerability).

## List of OpenPGP cards:
- [NitroKey](https://shop.nitrokey.com/shop) Look for _"Email encryption"_ in supported features.
- [Yubikey](https://www.yubico.com/products/yubikey-hardware/compare-products-series/) Look for _"open PGP"_ in supported features.
- [GnuK](https://www.fsij.org/category/gnuk.html) unlike others Gnuk is a project aiming to provide open firmware that impliments card emulation. NitroKey sells a version based on GnuK.

[^gpgsupport]: There are some models usually the cheapest ones that does not support this feature, look for GPG/PGP support.