Add preliminary script to try to import a gpg private key into the ssh
authorJameson Graef Rollins <jrollins@phys.columbia.edu>
Tue, 17 Jun 2008 18:35:06 +0000 (14:35 -0400)
committerJameson Graef Rollins <jrollins@phys.columbia.edu>
Tue, 17 Jun 2008 18:35:06 +0000 (14:35 -0400)
agent.

src/seckey2sshagent [new file with mode: 0755]

diff --git a/src/seckey2sshagent b/src/seckey2sshagent
new file mode 100755 (executable)
index 0000000..0e8d695
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+cleanup() {
+    echo -n "removing temp gpg home... "
+    rm -rf $FOO
+    echo "done."
+}
+
+trap cleanup EXIT
+
+GPGID="$1"
+
+idchars=$(echo $GPGID | wc -m)
+if [ "$idchars" -ne 17 ] ; then
+    echo "GPGID is not 16 characters ($idchars)."
+    exit 1
+fi
+
+FOO=$(mktemp -d)
+
+gpg --export-secret-key --export-options export-reset-subkey-passwd $GPGID | GNUPGHOME=$FOO gpg --import
+
+GNUPGHOME=$FOO gpg --edit-key $GPGID
+
+GNUPGHOME=$FOO gpg --export-secret-key $GPGID | openpgp2ssh $GPGID | ssh-add -c /dev/stdin