From 5075446c85e51043f3276175f38def63bc7953e6 Mon Sep 17 00:00:00 2001 From: Guido Trotter Date: Fri, 7 Oct 2011 15:42:07 -0400 Subject: [PATCH] Add ssh-keys example hook Signed-off-by: Guido Trotter Reviewed-by: Iustin Pop --- examples/hooks/ssh-keys | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) create mode 100755 examples/hooks/ssh-keys diff --git a/examples/hooks/ssh-keys b/examples/hooks/ssh-keys new file mode 100755 index 0000000..667b721 --- /dev/null +++ b/examples/hooks/ssh-keys @@ -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 -- 1.7.2.5