Skip to content

softwarecreations/npm-login-yubikey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM downloads Version Dependencies License Code size

npm-login-yubikey

Login to NPM, semi or fully automated, headless, scripted, non-interactive with a YubiCo YubiKey for 2FA (two factor authentication)

Project goals

  • No dependencies
  • Small, simple, easy to audit, yourself

Inspired by my previous project

Read that readme before using this.

Installation - 2 minute setup

Example username is: bob

  1. npm install -g npm-login-yubikey

  2. Install yubikey-manager aka ykman

  • Debian/Ubuntu/PopOS apt install yubikey-manager
  • Fedora/Redhat yum install yubikey-manager
  • In Python: pip install --user yubikey-manager
  • Windows choco install yubikey-manager
  • Mac brew install ykman
  1. Enable 2FA on your NPM account
  1. Click the link that says "Can't scan and need to type in the text code? Click here."

Let's pretend it says Your two-factor secret is: FOOBAR

  1. Save your secret as 'npm' into your YubiKey
  • (leave out --touch if you want fully-automated, instead of semi-automated)
  • ykman oath accounts add --touch npm FOOBAR
  1. Set environment variables for when you run npm-login-yubikey

On Linux, you could add this to your ~/.profile or ~/.bashrc On Windows/Mac, figure it out then please PR this Readme.

export NPM_USER='bob'
export NPM_PASS='best-password-ever'
export NPM_EMAIL='bob@email.com'
export NPM_OTPNAME='npm'
  1. Close and reopen terminal

  2. Run npm-login-yubikey

You should see: Logged in as bob on https://registry.npmjs.org/

Notes

  • Tested with YubiKey 5 Nano
  • We call the TOTP key 'npm' but you can call it whatever you like.

Provide 1 or more additional login options - optional

export NPM_EXTRA0='--registry=https://foo.com'
export NPM_EXTRA1='--scope=@orgname'
# ...
export NPM_EXTRA9='--future=proof'

Have fun!

Say thanks

Star the repo https://github.com/softwarecreations/npm-login-yubikey

Get notified of significant project changes

Subscribe to this issue #1

PR's or issues

Welcome

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors