summaryrefslogtreecommitdiff
path: root/src/seckey2sshagent
blob: d8e9b79ac2e86da91cf156de986a8434135e7b37 (plain)
  1. #!/bin/sh
  2. # seckey2sshagent: this is a hack of a script to cope with the fact
  3. # that openpgp2ssh currently cannot support encrypted secret keys.
  4. # the basic operating principal is:
  5. # export the secret key in encrypted format to a new keyring
  6. # remove the passphrase in that keyring
  7. # use that keyring with openpgp2ssh
  8. # Authors: Daniel Kahn Gillmor <dkg@fifthhorseman.net>,
  9. # Jameson Rollins <jrollins@fifthhorseman.net>
  10. cleanup() {
  11. echo -n "removing temp gpg home... "
  12. rm -rf $FOO
  13. echo "done."
  14. }
  15. trap cleanup EXIT
  16. GPGID="$1"
  17. idchars=$(echo $GPGID | wc -m)
  18. if [ "$idchars" -ne 17 ] ; then
  19. echo "GPGID is not 16 characters ($idchars)."
  20. exit 1
  21. fi
  22. FOO=$(mktemp -d)
  23. gpg --export-secret-key --export-options export-reset-subkey-passwd $GPGID | GNUPGHOME=$FOO gpg --import
  24. GNUPGHOME=$FOO gpg --edit-key $GPGID
  25. GNUPGHOME=$FOO gpg --export-secret-key $GPGID | openpgp2ssh $GPGID | ssh-add -c /dev/stdin