Login
You're viewing the functional.cafe public feed.
  • Aug 7, 2026, 10:14 PM

    2fa backup: I have several phones with Google Authenticator and no cloud backups. I wanted to extract and save the accounts and secrets on my computer.

    On each phone I took a screenshot of the exported qr codes, then used zbarimg (apt-get install zbar-tools) to extract the secrets. it outputs text files with a single line: QR-Code:otpauth-migration://offline?data=...

    Next I used google-authenticator-exporter to convert the text files into something easier to deal with; its output looks like

    Issuer: Mattermost
    Name: me@host
    Secret: 3MAJK2CULS6WKLVL
    -----------------------------------
    Issuer: Quake
    Name: username
    Secret: MFVWI2RUO54XU4
    -----------------------------------
    [...]
    

    I wrote a simple python script to fix problems (merge all the exported codes, remove duplicates, several entries had no "name" data, etc.), and output a merged text file. Lastly, I used 2fa to import all the secrets.

    The good news is 2fa reads from stdin so I could have my script output lines like

    echo MFVWI2RUO54XU4 | 2fa -add quake/username
    

    and simply pipe it to sh.

    The bad news is it takes all the secrets and writes them out to ~/.2fa -- unencrypted. I had to replace that with a gpg-encrypted file and a frontend script to 2fa.

    💬 0🔄 0⭐ 0