2FA (Two-Factor Authentication) application for CLI terminal with support to import/export andOTP files.

Overview

zauth

zauth is a 2FA (Two-Factor Authentication) application for terminal written in Go.


zauth

Features

  • Supports both TOTP and HOTP codes.
  • Add new entries directly from CLI.
    • support setting custom digits (default: 6)
    • support setting a custom period (TOTP) (default: 30)
    • support SHA1, SHA256 and SHA512 algorithms (TOTP)
  • Import/Export andOTP backups (encrypted files supported).
  • More upcoming features in What's next

If you would like any other app to be supported, please create an issue and (if possible) provide an unencrypted sample backup file. Of course I am accepting pull requests as well :)


Installation

$ go install github.com/grijul/zauth@latest

By default, zauth stores it entries in $HOME/.zauth directory.

Using Docker

zauth can be installed using docker as well. Running the following command pulls zauth image and runs zauth -h command.

$ docker run grijul/zauth:latest zauth -h

You can bind container's /root/.zauth directory to your host's $HOME/.zauth directory to use zauth.json from your host system. Something like this should work:

$ docker run -v $HOME/.zauth:/root/.zauth zauth:latest zauth

Important Note: There is only 1 docker image with latest tag on docker hub. Since there is no release cycle (as of now), I manually have to update the docker image whenever there are new commits. So the image is subject to be outdated and may not contain latest changes/fixes. I will try to update the image as frequently as possible.

If latest changes are desired, you can build docker image from source (it's easier than it sounds).


Building from source

  • Clone repository and cd into dir

      $ git clone https://github.com/grijul/zauth.git && cd zauth
    
  • Build using go build command

      $ go build .
    

Building docker image from source

  1. Clone repository and cd into dir

     $ git clone https://github.com/grijul/zauth.git && cd zauth
    
  2. Build docker image

     $ docker build -t zauth:latest .
    
  3. Run docker image

     $ docker run zauth:latest zauth -h
    

Examples

Print OTP

$ zauth

If zauth.json file exists, corresponding entries will be printed. Else the above command will give a file not found error.

This will simply print zauth entries with OTP and exit. If you wish to watch zauth entries update every second, you can use watch command.

$ watch -n1 zauth

Add new entry

$ zauth entry -new

A prompt will be displayed to capture necessary details (secret, issuer, etc..).


List entries

$ zauth entry -list

Import decrypted file

$ zauth import -file  -type 

-file flag tells zauth which file to import

-type flag tells zauth what type of file is being imported (supported files)


Import encrypted file

$ zauth import -file  -type  -decrypt

-decrypt flag tells zauth that import file is encrypted, and prompts user for decryption password. If not provided, files are assumed to be decrypted.


Import file (entries are overwritten)

$ zauth import -file  -type  -overwrite

-overwrite flag overwrites existing entries with new entries. If not provided, entries are appended.


Export file

$ zauth export -type  -encrypt

-encrypt flag tells zauth that exported file should be encrypted. If not provided, exported file is decrypted.

The file exported (encrypted/decrypted) is compatible with export_type app. This means user should be able to import this exported file back to export_type app.


Supported app files for import

  • andOTP - supports both encrypted/decrypted file. [-type=andotp]

Supported app files for export

  • andOTP - supports both encrypted/decrypted file. [-type=andotp]

What's next

  • zauth uses json file to store it's entries. At this moment, this json file is unencrypted. It'd be better we could have encrypted file instead.
  • Edit/Delete entries from CLI.

Contact

Feel free to get in touch with me via Twitter or Email.

License

MIT

You might also like...
Vault Authentication Azure Auth Method Demo Application
Vault Authentication Azure Auth Method Demo Application

This application demonstrates how applications hosted on Azure VMs can use managed identity to authenticate with HashiCorp Vault using the Azure Auth Method.

A simple authentication web application in Golang (using jwt)

Simple Authentication WebApp A simple authentication web app in Go (using JWT) Routes Path Method Data /api/v1/auth/register POST {"firstname":,"lastn

Simple tool to download files or web-pages with proxy-support and hardened crypto-algorithms

VBDownloader (with proxy-support behind firewall) Simple tool to download files or web-pages with proxy-support and hardened crypto-algorithms. This t

Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.

❗ Cache package has been moved to libcache repository Go-Guardian Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to

Go login handlers for authentication providers (OAuth1, OAuth2)
Go login handlers for authentication providers (OAuth1, OAuth2)

gologin Package gologin provides chainable login http.Handler's for Google, Github, Twitter, Facebook, Bitbucket, Tumblr, or any OAuth1 or OAuth2 auth

Package goth provides a simple, clean, and idiomatic way to write authentication packages for Go web applications.

Goth: Multi-Provider Authentication for Go Package goth provides a simple, clean, and idiomatic way to write authentication packages for Go web applic

HTTP Authentication middlewares

goji/httpauth httpauth currently provides HTTP Basic Authentication middleware for Go. It is compatible with Go's own net/http, goji, Gin & anything t

[DEPRECATED] Go package authcookie implements creation and verification of signed authentication cookies.

Package authcookie import "github.com/dchest/authcookie" Package authcookie implements creation and verification of signed authentication cookies. Co

Basic and Digest HTTP Authentication for golang http

HTTP Authentication implementation in Go This is an implementation of HTTP Basic and HTTP Digest authentication in Go language. It is designed as a si

Comments
Owner
Rijul Gulati
Rijul Gulati
Add MFA/2FA support in your CLI

go-oauth-cli-client Add MFA/2FA support in your CLI for IDPs that support OAuth 2.0 Authorization Code Flow Features MFA/2FA with minimal user interac

Eika Gruppen AS 6 Mar 23, 2022
Herbert Fischer 198 Oct 8, 2022
Yet another ykman Go lib for requesting OATH TOTP Multi-Factor Authentication Codes from Yubikey Devices

ykmangoath Ykman OATH TOTP with Go Yet another ykman Go lib for requesting OATH TOTP Multi-Factor Authentication Codes from Yubikey Devices. ?? Work-i

Ari Palo 4 Jul 3, 2022
Go based HTTP server with 2FA based on OTP (One-Time Password) manager like Google Authenticator

Go based HTTP server with 2FA based on OTP (One-Time Password) manager like Goog

Valentin Kuznetsov 7 Aug 21, 2022
Generate a generic library of 2FA tokens compatible with Google Authenticator

towfa Generate a generic library of 2FA tokens compatible with Google Authenticator go get -u github.com/golandscape/twofa $twofa "you secret" result:

golandscape 13 Mar 23, 2022
Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Paul Greenberg 697 Jan 8, 2023
A simple passwordless authentication middleware that uses only email as the authentication provider

email auth A simple passwordless authentication middleware that uses only email as the authentication provider. Motivation I wanted to restrict access

Miroslav Šedivý 5 Jul 27, 2022
Authorization and authentication. Learning go by writing a simple authentication and authorization service.

Authorization and authentication. Learning go by writing a simple authentication and authorization service.

Dinesh Bhattarai 0 Aug 5, 2022
The Single Sign-On Multi-Factor portal for web apps

Authelia is an open-source authentication and authorization server providing two-factor authentication and single sign-on (SSO) for your applications

Authelia 15.2k Jan 8, 2023
Example of a simple application which is powered by a third-party oAuth 2.0 server for it's authentication / authorization. Written in Golang.

go mod init github.com/bartmika/osin-thirdparty-example go get github.com/spf13/cobra go get github.com/openshift/osin go get github.com/openshift/osi

Bartlomiej Mika 0 Jan 4, 2022