yubikey-agent

command module
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2025 License: BSD-3-Clause Imports: 1 Imported by: 0

README

(my personal) yubikey-agent

This is a fork of filippo.io/yubikey-agent, a seamless ssh-agent for YubiKeys.

Key differences in this fork

  • multi-slot support: Configures all four PIV slots with different PIN and touch policies:
    • 9a (PIV Authentication): PIN required once, touch always required
    • 9c (Digital Signature): PIN always required, touch always required
    • 9d (Key Management): PIN required once, touch never required
    • 9e (Card Authentication): PIN never required, touch never required
  • Command-lines: Uses cobra for a more structured CLI with subcommands

Core features from the original project

  • 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/v2 and golang.org/x/crypto/ssh.

Installation

go install github.com/ncode/yubikey-agent@latest
yubikey-agent setup # generate new keys on the YubiKey

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

export SSH_AUTH_SOCK="${HOME}/.ssh/yubikey-agent.sock"
Windows

Windows support is currently WIP.

Commands

yubikey-agent list     # List available YubiKey devices
yubikey-agent setup    # Set up a YubiKey with SSH keys\
yubikey-agent unblock  # Unblock pin
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.

yubikey-agent unblock -s <serial>

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package agent implements an SSH agent that uses YubiKey PIV tokens for key operations.
Package agent implements an SSH agent that uses YubiKey PIV tokens for key operations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL