Skip to content

How to migrate your Google Authenticator database to pass otp?

Tad Fisher edited this page Aug 9, 2025 · 4 revisions

The script below transforms your Android's Google Authenticator sqlite3 database into a pass-otp-friendly string you can use on other of your devices in order to generate your TOTP tokens.

After dumping the database from a rooted android phone using these stackoverflow hints, you just need to adapt and run the following script:

#!/bin/bash

sqlite_run="sqlite3 -batch $HOME/tmp/google_authenticator_database.sqlite3"

#sqlite> .schema accounts
#CREATE TABLE accounts (_id INTEGER PRIMARY KEY, email TEXT NOT NULL, secret TEXT NOT NULL, counter INTEGER DEFAULT 0, type INTEGER, provider INTEGER DEFAULT 0, issuer TEXT DEFAULT NULL, original_name TEXT DEFAULT NULL);

# The idea is to extract and convert this:
#$ sqlite3 -batch ~/tmp/foo "select * from accounts;"
#2|Google:[email protected]|SECRET|0|0|0|Google|Google:[email protected]
#
# To this:
#otpauth://totp/[email protected]@Google?secret=SECRET&issuer=Google

sqlite_run 'SELECT printf('otpauth://totp/%s?secret=%s&issuer=%s', email, secret, issuer) FROM accounts'
Clone this wiki locally