diff --git a/README.md b/README.md index 1b71e9a..fae4daa 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ cat tokens | while IFS= read -r line; do done ``` +**Batch support** + +When environment variable named `AUTHY_EXPORT_PASSWORD` exists, `authy-export` does not ask for a password and uses the variable instead. Use with care! + ## LICENSE Copyright Alex Zorin 2019 diff --git a/cmd/authy-export/authy-export.go b/cmd/authy-export/authy-export.go index eb4fe01..afc2cd0 100644 --- a/cmd/authy-export/authy-export.go +++ b/cmd/authy-export/authy-export.go @@ -68,10 +68,13 @@ func main() { } // We'll need the prompt the user to give the decryption password - log.Printf("Please provide your Authy TOTP backup password: ") - pp, err := terminal.ReadPassword(int(os.Stdin.Fd())) - if err != nil { - log.Fatalf("Failed to read the password: %v", err) + pp := []byte(os.Getenv("AUTHY_EXPORT_PASSWORD")) + if len(pp) == 0 { + log.Printf("Please provide your Authy TOTP backup password: ") + pp, err = terminal.ReadPassword(int(os.Stdin.Fd())) + if err != nil { + log.Fatalf("Failed to read the password: %v", err) + } } // Print out in https://github.com/google/google-authenticator/wiki/Key-Uri-Format format