summaryrefslogtreecommitdiff
path: root/src/seckey2sshagent
blob: 1266db5b329987af795f1b6ea286a33f27eb5691 (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... " 1>&2
  12. rm -rf $FOO
  13. echo "done." 1>&2
  14. }
  15. trap cleanup EXIT
  16. #GPGID="$1"
  17. GPGID=$(echo "$1" | cut -c 25-)
  18. FOO=$(mktemp -d)
  19. gpg --export-secret-key $GPGID | GNUPGHOME="$FOO" gpg --import
  20. # idea to script the password stuff. not working.
  21. # read -s -p "enter gpg password: " PASSWD; echo
  22. # cmd=$(cat <<EOF
  23. # passwd
  24. # $PASSWD
  25. # \n
  26. # \n
  27. # \n
  28. # yes
  29. # save
  30. # EOF
  31. # )
  32. # echo -e "$cmd" | GNUPGHOME="$FOO" gpg --command-fd 0 --edit-key $GPGID
  33. GNUPGHOME="$FOO" gpg --edit-key $GPGID
  34. ln -s /dev/stdin "$FOO"/openpgp
  35. GNUPGHOME="$FOO" gpg --export-secret-key $GPGID | \
  36. openpgp2ssh $GPGID | ssh-add -c "$FOO"/openpgp