Skip to content

Instantly share code, notes, and snippets.

@nillia
Forked from cshtdd/keybase-to-rsa.sh
Created November 6, 2017 21:57
Show Gist options
  • Save nillia/cb9e2164cc50896d16a1e5ac4d9e0933 to your computer and use it in GitHub Desktop.
Save nillia/cb9e2164cc50896d16a1e5ac4d9e0933 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Start Export Process"
echo "Log into Keybase..."
keybase login
echo "Exporting your PGP keys..."
keybase pgp export -o keybase.public.key
keybase pgp export -s -o keybase.private.key
echo "Importing your Keybase keys..."
gpg -q --import keybase.public.key
gpg -q --allow-secret-key-import --import keybase.private.key
HASH=$(gpg --list-keys | grep -A1 '^pub\s*.*\/*.\s.*' | tail -n 1 | sed -e 's/^[ \t]*//')
# We clean the passphrase to export the key
gpg --passwd $HASH
echo "Generating RSA keys..."
gpg --export-secret-keys $HASH | openpgp2ssh $HASH > id_rsa
chmod 400 id_rsa
gpg --export $HASH | openpgp2ssh $HASH > id_rsa.pub
echo "Cleaning up..."
gpg --delete-secret-key $HASH
gpg --delete-keys $HASH
rm *.key
echo "Success"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment