#!/bin/bash # seckey2sshagent: this is a hack of a script to cope with the fact # that openpgp2ssh currently cannot support encrypted secret keys. # the basic operating principal is: # export the secret key in encrypted format to a new keyring # remove the passphrase in that keyring # use that keyring with openpgp2ssh # Authors: Daniel Kahn Gillmor , # Jameson Rollins explanation() { cat < followed by the empty string for the new password. GPG will ask you if you're really sure. Answer yes, because this is only relevant to the temporary keyring. Then, do: save At this point, your key will be added to your running ssh-agent with the alias 'monkeysphere-key' and seckey2sshagent should terminate. You can check on it with: ssh-add -l EOF } cleanup() { echo -n "removing temp gpg home... " 1>&2 rm -rf "$TMPPRIVATE" echo "done." 1>&2 } export_sec_key() { gpg --export-secret-key "$GPGID" | GNUPGHOME="$TMPPRIVATE" gpg --import GNUPGHOME="$TMPPRIVATE" gpg --edit-key "$GPGID" # idea to script the password stuff. not working. # read -s -p "enter gpg password: " PASSWD; echo # cmd=$(cat < "$TMPPRIVATE/key" # passprotect file ssh-keygen -f "${TMPPRIVATE}/key" -p # move into place mv "${TMPPRIVATE}/key" "$FILE" # export public key gpg --export "$GPGID" | openpgp2ssh "$GPGID" > "${FILE}.pub" # otherwise add to agent else KEYNAME='MonkeySphere Key '$(echo "$GPGID" | tr -c -d '0-9a-fA-F')'' # creating this alias so the key is named "monkeysphere-key" in the # comment stored by the agent, while never being written to disk in # SSH form: ln -s /dev/stdin "${TMPPRIVATE}/${KEYNAME}" # export secret key to agent export_sec_key | (cd "$TMPPRIVATE" && ssh-add -c "$KEYNAME") fi done