• Stars
    star
    2,644
  • Rank 17,295 (Top 0.4 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

yubikey-agent is a seamless ssh-agent for YubiKeys.

yubikey-agent

yubikey-agent is a seamless ssh-agent for YubiKeys.

  • Easy to use. A one-command setup, one environment variable, and it just runs in the background.
  • Indestructible. Tolerates unplugging, sleep, and suspend. Never needs restarting.
  • Compatible. Provides a public key that works with all services and servers.
  • Secure. The key is generated on the YubiKey and can't be extracted. Every session requires the PIN, every login requires a touch. Setup takes care of PUK and management key.

Written in pure Go, it's based on github.com/go-piv/piv-go and golang.org/x/crypto/ssh.

Installation

macOS

brew install yubikey-agent
brew services start yubikey-agent
yubikey-agent -setup # generate a new key on the YubiKey

Then add the following line to your ~/.zshrc and restart the shell.

export SSH_AUTH_SOCK="$(brew --prefix)/var/run/yubikey-agent.sock"

Linux

Arch

On Arch, use the yubikey-agent package from the AUR.

git clone https://aur.archlinux.org/yubikey-agent.git
cd yubikey-agent && makepkg -si

systemctl daemon-reload --user
sudo systemctl enable --now pcscd.socket
systemctl --user enable --now yubikey-agent

export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/yubikey-agent/yubikey-agent.sock"

NixOS / nixpkgs

On NixOS unstable and 20.09 (unreleased at time of writing), you can add this to your /etc/nixos/configuration.nix:

services.yubikey-agent.enable = true;

This installs yubikey-agent and sets up a systemd unit to start yubikey-agent for you.

On other systems using nix, you can also install from nixpkgs:

nix-env -iA nixpkgs.yubikey-agent

This installs the software but does not install a systemd unit. You will have to set up service management manually (see below).

Other systemd-based Linux systems

On other systemd-based Linux systems, follow the manual installation instructions.

Packaging contributions are very welcome.

FreeBSD

Install the yubikey-agent port.

Windows

Windows support is currently WIP.

Advanced topics

Coexisting with other ssh-agents

It's possible to configure ssh-agents on a per-host basis.

For example to only use yubikey-agent when connecting to example.com, you'd add the following lines to ~/.ssh/config instead of setting SSH_AUTH_SOCK.

Host example.com
    IdentityAgent /usr/local/var/run/yubikey-agent.sock

To use yubikey-agent for all hosts but one, you'd add the following lines instead. In both cases, you can keep using ssh-add to interact with the main ssh-agent.

Host example.com
    IdentityAgent $SSH_AUTH_SOCK

Host *
    IdentityAgent /usr/local/var/run/yubikey-agent.sock

Conflicts with gpg-agent and Yubikey Manager

yubikey-agent takes a persistent transaction so the YubiKey will cache the PIN after first use. Unfortunately, this makes the YubiKey PIV and PGP applets unavailable to any other applications, like gpg-agent and Yubikey Manager. Our upstream is investigating solutions to this annoyance.

If you need yubikey-agent to release its lock on the YubiKey, send it a hangup signal or use ssh-add's "delete all identities" flag. Likewise, you might have to kill gpg-agent after use for it to release its own lock.

ssh-add -D

This does not affect the FIDO2 functionality.

Changing PIN and PUK

Use YubiKey Manager to change the PIN and PUK.

yubikey-agent -setup sets the PUK to the same value as the PIN.

killall -HUP yubikey-agent
ykman piv access change-pin
ykman piv access change-puk

Unblocking the PIN with the PUK

If the wrong PIN is entered incorrectly three times in a row, YubiKey Manager can be used to unlock it.

yubikey-agent -setup sets the PUK to the same value as the PIN.

ykman piv access unblock-pin

If the PUK is also entered incorrectly three times, the key is permanently irrecoverable. The YubiKey PIV applet can be reset with yubikey-agent --setup --really-delete-all-piv-keys.

Manual setup and technical details

yubikey-agent only officially supports YubiKeys set up with yubikey-agent -setup.

In practice, any PIV token with an RSA or ECDSA P-256 key and certificate in the Authentication slot should work, with any PIN and touch policy. Simply skip the setup step and use ssh-add -L to view the public key.

yubikey-agent -setup generates a random Management Key and stores it in PIN-protected metadata.

Alternatives

Native FIDO2

Recent versions of OpenSSH support using FIDO2 tokens directly. Since those are their own key type, they require server-side support, which has only recently reached Debian and GitHub.

FIDO2 SSH keys by default don't require a PIN, and require a private key file, acting more like a second factor. yubikey-agent keys always require PINs and can be ported to a different machine simply by plugging in the YubiKey. (With recent enough tokens such as a YubiKey 5, a similar setup can be achieved by using the verify-required and resident options, after setting a FIDO2 PIN with YubiKey Manager: the private key file will still be required, but it can be regenerated from the YubiKey.)

gpg-agent

gpg-agent can act as an ssh-agent, and it can use keys stored on the PGP applet of a YubiKey.

This requires a finicky setup process dealing with PGP keys and the gpg UX, and seems to lose track of the YubiKey and require restarting all the time. Frankly, I've also had enough of PGP and GnuPG.

ssh-agent and PKCS#11

ssh-agent can load PKCS#11 applets to interact with PIV tokens directly. There are two third-party PKCS#11 providers for YubiKeys (OpenSC and ykcs11) and one that ships with macOS (man 8 ssh-keychain).

The UX of this solution is poor: it requires calling ssh-add to load the PKCS#11 module and to unlock it with the PIN (as the agent has no way of requesting input from the client during use, a limitation that yubikey-agent handles with pinentry), and needs manual reloading every time the YubiKey is unplugged or the machine goes to sleep.

The ssh-agent that ships with macOS (which is pretty cool, as it starts on demand and is preconfigured in the environment) also has restrictions on where the .so modules can be loaded from. It can see through symlinks, so a Homebrew-installed /usr/local/lib/libykcs11.dylib won't work, while a hard copy at /usr/local/lib/libykcs11.copy.dylib will.

/usr/lib/ssh-keychain.dylib works out of the box, but only with RSA keys. Key generation is undocumented.

Secretive and SeKey

Secretive and SeKey are similar projects that use the Secure Enclave to store the private key and Touch ID for authorization. The Secure Enclave has so far a worse security track record compared to YubiKeys.

pivy-agent

pivy-agent is part of a suite of tools to work with PIV tokens. It's similar to yubikey-agent, and inspired its design.

The main difference is that it requires unlocking via ssh-add -X rather than using a graphical pinentry, and it caches the PIN in memory rather than relying on the device PIN policy. It's also written in C.

yubikey-agent also aims to provide an even smoother setup process.

More Repositories

1

mkcert

A simple zero-config tool to make locally trusted development certificates with any names you'd like.
Go
48,512
star
2

age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
Go
16,957
star
3

Heartbleed

A checker (site and tool) for CVE-2014-0160
Go
2,307
star
4

whoami.filippo.io

A ssh server that knows who you are. $ ssh whoami.filippo.io
Go
2,218
star
5

passage

A fork of password-store (https://www.passwordstore.org) that uses age (https://age-encryption.org) as backend.
Shell
790
star
6

gvt

gvt was a minimal go vendoring tool, based on gb-vendor. Today, you want to use modules instead.
Go
730
star
7

homebrew-musl-cross

Homebrew Formula for static-friendly musl-based GCC macOS-to-Linux cross-compilers
Ruby
558
star
8

captive-browser

A dedicated Chrome instance to log into captive portals without messing with DNS settings.
Go
434
star
9

awesome-age

A collection of projects and resources in the age file encryption ecosystem.
322
star
10

mostly-harmless

A bag of various unrelated projects with varying levels of serviceability and destructiveness.
JavaScript
221
star
11

CVE-2016-2107

Simple test for the May 2016 OpenSSL padding oracle (CVE-2016-2107)
Go
185
star
12

vendorcheck

Check that all your Go dependencies are properly vendored
Go
178
star
13

edwards25519

filippo.io/edwards25519 β€” A safer, faster, and more powerful low-level edwards25519 Go implementation.
Go
133
star
14

mlkem768

A Go implementation of the quantum-resistant key encapsulation method ML-KEM (formerly known as Kyber).
Go
131
star
15

sunlight

A Certificate Transparency log implementation and monitoring API designed for scalability, ease of operation, and reduced cost.
Go
125
star
16

ed25519-dalek-rustgo

Wrapper for curve25519-dalek using rustgo, a technique to directly call Rust code from Go programs with near-zero overhead, meant to replace manually written assembly.
Go
121
star
17

tracetools

Tools to process Go trace logs into various profiles. Complement for "go tool trace".
Go
111
star
18

typage

A TypeScript implementation of the age file encryption format, based on libsodium.
TypeScript
97
star
19

zcash-mini

A minimal portable Zcash z-address generator for offline / paper wallets
Go
96
star
20

BERserk

A Go implementation of the BERserk attack against Mozilla NSS ASN.1 parsing of PKCS#1 RSA signatures with e = 3. Complete of a certificate generation tool, works with CAs in the trust store.
Go
94
star
21

hstools

Library and tools to interact with and analyze Tor HSDirs.
Go
72
star
22

homebrew-gomod

A brew command to cleanly install binaries from Go modules.
Shell
68
star
23

blockchainr

Exploiting ECDSA Failures in the Bitcoin Blockchain
Go
61
star
24

openbsd-fde-crack

Some code to bruteforce OpenBSD softraid encrypted drives - NOT A READY-TO-USE TOOL
Go
57
star
25

intermediates

Package filippo.io/intermediates embeds a bundle of known unexpired, unrevoked intermediate certificates chaining to roots in the Mozilla Root Program
Go
55
star
26

travis-cron

This web app allows you to trigger Travis CI builds periodically
Python
55
star
27

gorebuild

Extract the import path of Go binaries and rebuild them. No more stale GOROOT.
Go
54
star
28

nistec

NIST P elliptic curves (re-exported from crypto/internal/nistec)
Assembly
47
star
29

otherport

LD_PRELOAD hack to redirect connections to other ports
C
42
star
30

powersoftau

An independent implementation of the Powers of Tau MPC ceremony.
Go
33
star
31

HNTitles

Tweet probabilistically generated HN post titles.
Python
29
star
32

go-cpace-ristretto255

An EXPERIMENTAL Go implementation of the CPace PAKE, instantiated with the ristretto255 group.
Go
28
star
33

alum

A forwarding mail server inspired by @alum.mit.edu
Go
18
star
34

xaes256gcm

Package xaes256gcm implements the XAES-256-GCM extended-nonce AEAD.
Go
18
star
35

FiloSottile

18
star
36

keygen

Deterministic key generation for Go.
Go
17
star
37

axel

Axel Download Accelerator [git mirror]
C
15
star
38

b2

Efficient, idiomatic Go library for Backblaze B2 Cloud Storage.
Go
13
star
39

bigmod

A constant-time library for big integers modulo a prime, usable for cryptographic applications. Exported from crypto/internal/bigmod, the backend of crypto/rsa and crypto/ecdsa.
Go
13
star
40

crypto.py

A collection of pure Python crypto implementations. All modules are standalone. Available in Python 2 and Python 3 flavors!
Python
10
star
41

litetlog

A collection of liteweight transparency logging tools, compatible with the Sigsum and Omniwitness ecosystems.
Go
8
star
42

Pendolo-OpenCV

C++
6
star
43

Griffith

Media collection manager [MIRROR]
Python
5
star
44

blog.filippo.io

blog.filippo.io theme. Slightly tweaked 0.9.4 Casper. Pretty please, don't just clone it <3
CSS
4
star
45

homebrew-lite

Modified homebrew-core formula with fewer dependencies.
Ruby
3
star
46

torspec

Forked from git.torproject.org/torspec.git
Python
2
star
47

.github

2
star
48

hs-api-playground

Playground for the Hacker School API
Python
1
star
49

WPA-hazard

Deep into the default WPA generation algorithms
C
1
star
50

homebrew-age

1
star
51

filosottile.github.io

An empty repository for redirecting filosottile.github.io to filippo.io (https://github.com/FiloSottile/filippo.io).
1
star
52

crypto-tls-bogo-shim

A shim to test Go crypto/tls with the BoringSSL test suite. Which is based on crypto/tls. So meta.
Go
1
star