Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation of andOTP migration #136

Open
BenSartor opened this issue Jan 9, 2021 · 0 comments
Open

Documentation of andOTP migration #136

BenSartor opened this issue Jan 9, 2021 · 0 comments

Comments

@BenSartor
Copy link

Hi,

thanks a lot for pass-otp!

Here is a little script, I used to migrate from andOTP.

#! /bin/bash

## exit if an error occurs or on unset variables
set -eu -o pipefail

## example usage
## gpg --decrypt otp_accounts_2021-01-09_16-20-41.json.gpg.pgp | ./andOTP2pass-otp.sh

jq -c '.[]' | while read ENTRY; do
    TYPE=$(echo "${ENTRY}" | jq -r .type | tr "[:upper:]" "[:lower:]")
    LABEL=$(echo "${ENTRY}" | jq -r .label)
    LABEL_ESCAPED=$(echo "${LABEL}" | jq -Rr @uri)
    LABEL_FILE=$(echo "${LABEL}" | tr "[:upper:]" "[:lower:]" | sed "s/[[:space:]]/_/g" | sed "s/:/-/g" | sed "s/\./-/g" | sed "s/@/-/g" | sed "s/ö/oe/g")
    SECRET=$(echo "${ENTRY}" | jq -r .secret)
    ISSUER=$(echo "${ENTRY}" | jq -r .issuer)
    DIGITS=$(echo "${ENTRY}" | jq -r .digits)
    PERIOD=$(echo "${ENTRY}" | jq -r .period)
    ALGORITHM=$(echo "${ENTRY}" | jq -r .algorithm)

    KEY_URI="otpauth://${TYPE}/${LABEL_ESCAPED}?secret=${SECRET}"
    if [ -n "${ISSUER}" ] ; then
        KEY_URI="${KEY_URI}&issuer=${ISSUER}"
    fi
    if [ -n "${DIGITS}" ] ; then
        KEY_URI="${KEY_URI}&digits=${DIGITS}"
    fi
    if [ -n "${PERIOD}" ] ; then
        KEY_URI="${KEY_URI}&period=${PERIOD}"
    fi
    if [ -n "${ALGORITHM}" ] ; then
        KEY_URI="${KEY_URI}&algorithm=${ALGORITHM}"
    fi

    echo "${KEY_URI}" #| pass otp insert "andOTP/${LABEL_FILE}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant