Add ssh-keys example hook
[ext/instance-debootstrap.git] / examples / hooks / ssh-keys
1 #!/bin/bash
2
3 if [ -z "$TARGET" -o ! -d "$TARGET" ]; then
4   echo "Missing target directory"
5   exit 1
6 fi
7
8 # user to give access to. can be hardcoded or fetched from some other place
9 : ${USER:="myuser"}
10 # keytype: rsa or dsa
11 : ${KEYTYPE:="rsa"}
12
13 if [ -f /home/$USER/.ssh/id_$KEYTYPE.pub ]; then
14   install -D -m 0700 -o root -g root \
15     /home/$USER/.ssh/id_$KEYTYPE.pub $TARGET/root/.ssh/authorized_keys
16 fi
17
18 exit 0