Add ssh-keys example hook
authorGuido Trotter <ultrotter@google.com>
Fri, 7 Oct 2011 19:42:07 +0000 (15:42 -0400)
committerGuido Trotter <ultrotter@google.com>
Mon, 10 Oct 2011 17:41:24 +0000 (13:41 -0400)
Signed-off-by: Guido Trotter <ultrotter@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

examples/hooks/ssh-keys [new file with mode: 0755]

diff --git a/examples/hooks/ssh-keys b/examples/hooks/ssh-keys
new file mode 100755 (executable)
index 0000000..667b721
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
+  echo "Missing target directory"
+  exit 1
+fi
+
+# user to give access to. can be hardcoded or fetched from some other place
+: ${USER:="myuser"}
+# keytype: rsa or dsa
+: ${KEYTYPE:="rsa"}
+
+if [ -f /home/$USER/.ssh/id_$KEYTYPE.pub ]; then
+  install -D -m 0700 -o root -g root \
+    /home/$USER/.ssh/id_$KEYTYPE.pub $TARGET/root/.ssh/authorized_keys
+fi
+
+exit 0