Skip to content
/ ykmango Public

🔑 Prompt a YubiKey device to generate an OATH code

License

Notifications You must be signed in to change notification settings

joshdk/ykmango

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License GoDoc Go Report Card CircleCI CodeCov

YKManGo

🔑 Prompt a YubiKey device to generate an OATH code

Installing

You can fetch this library by running the following

go get -u github.com/joshdk/ykmango

Additionally, this library has a runtime dependency on ykman which must be installed before use.

Usage

import (
	"fmt"
	"github.com/joshdk/ykmango"
)

// List the currently configured OATH slot names.
names, err := ykman.List()
if err != nil {
	panic(err.Error())
}

for _, name := range names {
	fmt.Printf("Found code named: %s\n", name)
	// Found code named: aws-mfa
}

// Generate an OATH code using the given slot name.
// You may need to touch your YubiKey device if the
// slot is configured to require touch.
code, err := ykman.Generate("aws-mfa")
if err != nil {
	panic(err.Error())
}

fmt.Printf("Your code is: %s\n", code)
// Your code is: 150509

License

This library is distributed under the MIT License, see LICENSE.txt for more information.