44
content/blog/gauth-backup.md
Normal file
44
content/blog/gauth-backup.md
Normal file
@@ -0,0 +1,44 @@
|
||||
+++
|
||||
date = "2017-06-12T11:44:46+02:00"
|
||||
title = "How to: backup google authenticator app two-factor secrets"
|
||||
|
||||
+++
|
||||
|
||||
Quick and dirty:
|
||||
|
||||
- Connect your device to the PC via USB
|
||||
- Enable debugging mode
|
||||
- From the terminal:
|
||||
|
||||
```bash
|
||||
adb root
|
||||
adb pull /data/data/com.google.android.apps.authenticator2/databases/databases
|
||||
sqlite3 ./databases "select * from accounts" > ./gauth_backup.txt
|
||||
```
|
||||
|
||||
If you want to generate an auth code from a TOTP secret you can use `oathtool`:
|
||||
|
||||
```bash
|
||||
oathtool --base32 --totp "<secret>"
|
||||
```
|
||||
|
||||
Enjoy!
|
||||
|
||||
---
|
||||
|
||||
Pro tip: to generate all the QR codes from the `sqlite` database you could use this python script (which requires the `qrcode` module):
|
||||
|
||||
```py
|
||||
import qrcode
|
||||
import sqlite3
|
||||
conn = sqlite3.connect('databases')
|
||||
c = conn.cursor()
|
||||
|
||||
for idx, (email, secret, issuer) in enumerate(c.execute("SELECT email,secret,issuer FROM accounts").fetchall()):
|
||||
url = 'otpauth://totp/{}?secret={}&issuer={}'.format(email, secret, issuer)
|
||||
print url
|
||||
im = qrcode.make(url)
|
||||
im.save('{}.png'.format(idx))
|
||||
```
|
||||
|
||||
(source: [thouis](https://github.com/thouis))
|
Reference in New Issue
Block a user