• Stars
    star
    1,538
  • Rank 30,420 (Top 0.6 %)
  • Language
    Go
  • License
    BSD 3-Clause "New...
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Two-factor authentication on the command line

2fa is a two-factor authentication agent.

Usage:

go get -u rsc.io/2fa

2fa -add [-7] [-8] [-hotp] name
2fa -list
2fa name

2fa -add name adds a new key to the 2fa keychain with the given name. It prints a prompt to standard error and reads a two-factor key from standard input. Two-factor keys are short case-insensitive strings of letters A-Z and digits 2-7.

By default the new key generates time-based (TOTP) authentication codes; the -hotp flag makes the new key generate counter-based (HOTP) codes instead.

By default the new key generates 6-digit codes; the -7 and -8 flags select 7- and 8-digit codes instead.

2fa -list lists the names of all the keys in the keychain.

2fa name prints a two-factor authentication code from the key with the given name. If -clip is specified, 2fa also copies to the code to the system clipboard.

With no arguments, 2fa prints two-factor authentication codes from all known time-based keys.

The default time-based authentication codes are derived from a hash of the key and the current time, so it is important that the system clock have at least one-minute accuracy.

The keychain is stored unencrypted in the text file $HOME/.2fa.

Example

During GitHub 2FA setup, at the “Scan this barcode with your app” step, click the “enter this text code instead” link. A window pops up showing “your two-factor secret,” a short string of letters and digits.

Add it to 2fa under the name github, typing the secret at the prompt:

$ 2fa -add github
2fa key for github: nzxxiidbebvwk6jb
$

Then whenever GitHub prompts for a 2FA code, run 2fa to obtain one:

$ 2fa github
268346
$

Or to type less:

$ 2fa
268346	github
$ 

More Repositories

1

rf

A refactoring tool for Go
Go
668
star
2

c2go

C to Go translation tool supporting Go toolchain migration
Go
497
star
3

pdf

PDF reader
Go
488
star
4

letsencrypt

Manage TLS certificates automatically via LetsEncrypt.org
Go
466
star
5

grind

Grind polishes Go programs.
Go
461
star
6

goversion

Print version used to build Go executables
Go
265
star
7

gt

go test but faster (cached)
Go
253
star
8

corpus

Corpus of interesting Go code
Go
193
star
9

qr

QR codes
Go
192
star
10

web

basic web site serving framework
Go
154
star
11

tmplfunc

Go templates invoked as functions
Go
145
star
12

tlogdb

Reusable transparent log database
Go
141
star
13

benchstat

Benchstat computes and compares statistics about benchmarks.
Go
139
star
14

tiddly

TiddlyWiki (actually TiddlyWeb) server for Google App Engine
HTML
123
star
15

go-import-redirector

HTTP server for a custom 'go get' domain
Go
114
star
16

quote

Pithy sayings.
Go
99
star
17

github

Go
96
star
18

diff

Diff(1)
Go
91
star
19

tmp

/tmp
Go
89
star
20

swtch

swtch.com web server
Go
88
star
21

markdown

Basic Markdown parser and HTML generator
Go
71
star
22

zipmerge

Go
52
star
23

rsc

Automatically exported from code.google.com/p/rsc
Go
50
star
24

xstd

importable versions of parts of the Go standard library
Go
49
star
25

dbstore

Data structure interface to database/sql
Go
48
star
26

cmd

Commands
Go
48
star
27

binaryregexp

Go regexp for binary/latin-1 data
Go
44
star
28

getopt

getopt(3)-style Go flag parser
Go
43
star
29

benchgraffiti

benchmark graffiti (formerly code.google.com/p/benchgraffiti)
Go
39
star
30

todo

Trivial to-do lists
Go
35
star
31

pprof_mac_fix

Assembly
35
star
32

quine

Quines
Go
35
star
33

grepdiff

grep for diffs
Go
34
star
34

mailgun

Utilities for interacting with mailgun.com.
Go
28
star
35

sizeof

print sizes of Go data structures
Go
26
star
36

sqlite

Go sqlite3 database/sql driver
Go
24
star
37

nop

No-op
Go
24
star
38

perf2pprof

Convert Linux perf traces to Go pprof format
Go
22
star
39

plan9vmware

Ancient source code for Plan 9 VMware tools
C
21
star
40

x86

x86 code manipulation
Go
21
star
41

edit

Byte buffer editor
Go
21
star
42

tcat

Table cat
Go
20
star
43

arm

arm code manipulation
Go
20
star
44

devweb

Development web server
Go
19
star
45

empty

Empty repository.
16
star
46

gitfs

Remote Git repos as fs.FS file systems.
Go
14
star
47

compilebench

Compiler benchmarking
Go
13
star
48

ghostscript-9.06

Ghostscript 9.06 (GPL-, not AGPL-licensed)
C
10
star
49

gocachelogstat

Go
10
star
50

hello

hello
Go
10
star
51

cloud

vaporware
Go
9
star
52

sampler

sampler
Go
9
star
53

toolstash

Save, run, and restore a known good copy of the Go toolchain.
Go
9
star
54

script

Script engine, especially good for tests
Go
5
star
55

vgotest1

vgotest1
Go
2
star
56

legacytest

legacytest
Go
2
star
57

vgotest3

vgotest3 imports vgotest-backward
Go
2
star
58

deptest5-d

Go
1
star
59

dt1-a

1
star
60

go-get-test-pdf

Go
1
star
61

dt2-main

Go
1
star
62

goobjdump

Go objdump file dumper
Go
1
star
63

go-get-issue-9357

Go
1
star
64

vgotest-backward

vgotest backward
Go
1
star
65

vgotest5

vgotest5
Go
1
star
66

ppc64

ppc64 code manipulation
Go
1
star
67

re1

Regexp code for https://swtch.com/~rsc/regexp/
C
1
star