Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Aldaviva/8d2708d2f37ac1ab490fa5902ee6dc91 to your computer and use it in GitHub Desktop.
Save Aldaviva/8d2708d2f37ac1ab490fa5902ee6dc91 to your computer and use it in GitHub Desktop.
Export OAuth one-time passwords from Google Authenticator and import them into KeePass

Import OAuth TOTP from Google Authenticator into Keepass

  1. Export a QR code from Google Authenticator
    1. Open the Google Authenticator Android app
    2. Tap ☰ › Transfer accounts › Export accounts
    3. Laboriously deselect all accounts except the one you want to export
    4. Tap Next
  2. Decode the otpauth-migration URI from the QR code
    1. Take a screenshot of the QR code on the screen by holding Power+Volume Down
    2. Open the screenshot in Google Photos or another app that can decode QR codes
    3. Tap Lens, which will automatically locate the QR code and decode the text into an otpauth-migration URI
    4. Tap Copy text to copy the otpauth-migration URI
    5. Send this otpauth-migration URI to a computer running Windows, Linux, or Mac OS using any text transfer technique, for example with Google Keep, OneNote, or Evernote
  3. Convert the otpauth-migration URI to an otpauth URI
    1. On the computer, download the latest release of dim13/otpauth
    2. Extract the .tgz file (tar -xzf otpauth-*.tgz)
    3. Run otpauth -link $uri, where $uri is the otpauth-migration URI you transferred in step 2.v
    4. Copy the output otpauth URI
  4. Import into KeePass
    1. Open KeePass
    2. Create or edit an entry
    3. Click 🪛 Tools › OTP Generator Settings… › Import 'otpauth://' URI…
    4. Paste the otpauth URI which you copied in step 3.iv, then click OK
    5. Confirm that the OTP shown in the KeePass preview matches the OTP shown in Google Authenticator
    6. Click OK to close all of the dialog boxes, then save your KeePass database

Using OTPs in KeePass

Manually

  1. Select the entry, then press Ctrl+T to copy the TOTP

Auto-Type

  1. Edit the entry
  2. In the Auto-Type tab, click Override default sequence, then click Edit
  3. In Use custom keystroke sequence, insert the {TIMEOTP} placeholder (for TOTP) or {HMACOTP} (for HOTP) in the correct location in the keystroke sequence for the given authentication flow
  4. Click OK to close all of the dialog boxes, then save your KeePass database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment