2 # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
4 # Monkeysphere import-subkey subcommand
6 # The monkeysphere scripts are written by:
7 # Jameson Rollins <jrollins@finestructure.net>
8 # Jamie McClelland <jm@mayfirst.org>
9 # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
11 # They are Copyright 2008-2009, and are all released under the GPL,
14 # import an existing ssh key as a gpg subkey
16 ## 2009-02-20 00:49:11-0500: This is not implemented yet, because we
17 ## don't currently have a good way to manipulate the user's OpenPGP
18 ## secret key such that we could make a proper subkey binding
28 failure "import-subkey is not implemented yet. We welcome patches. Sorry!"
33 # check that key file specified
34 if [ -z "$sshKeyFile" ] ; then
35 failure "Must specify ssh key file to import, or specify '-' for stdin."
38 # check that the keyID is unique
39 keyID=$(check_gpg_sec_key_id "$@")
41 # check that an authentication subkey does not already exist
42 check_gpg_authentication_subkey "$keyID"
44 # setup the temp fifo dir for retrieving the key password
45 log debug "creating password fifo..."
46 fifoDir=$(msmktempdir)
47 trap "rm -rf $fifoDir" EXIT
48 (umask 077 && mkfifo "$fifoDir/pass")
50 # import ssh key to as authentication subkey
51 if [ "$sshKeyFile" = '-' ] ; then
52 log verbose "importing ssh key from stdin..."
53 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" \
54 | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --import &
56 log verbose "importing ssh key from file '$sshKeyFile'..."
57 PEM2OPENPGP_USAGE_FLAGS=authenticate pem2openpgp "$userID" <"$sshKeyFile" \
58 | gpg_user --passphrase-fd 3 3< "$fifoDir/pass" --expert --command-fd 0 --import &
61 # get the password if needed
62 passphrase_prompt "Please enter your passphrase for $keyID: " "$fifoDir/pass"