From d6aabdf6b928cdedf1900907f5b62be77b8c187b Mon Sep 17 00:00:00 2001 From: Henning Heinold Date: Fri, 19 Sep 2014 17:27:44 +0200 Subject: [PATCH] recipes-images: add fragement to install sshkeys Fixes: partly SYS#518 --- recipes-apps/images/image-sshkey.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 recipes-apps/images/image-sshkey.inc diff --git a/recipes-apps/images/image-sshkey.inc b/recipes-apps/images/image-sshkey.inc new file mode 100644 index 0000000..ecbffff --- /dev/null +++ b/recipes-apps/images/image-sshkey.inc @@ -0,0 +1,18 @@ + +hostsshkeysfile = "${@d.getVar('SSH_KEYS_FILE', True) or ''}" + +ROOTFS_POSTPROCESS_COMMAND += "copy_ssh_keys;" + +copy_ssh_keys() { + if [ -n "${hostsshkeysfile}" ]; then + if [ -r "${hostsshkeysfile}" ]; then + echo "Installing sshkeys from ${hostsshkeysfile}" + mkdir -p ${IMAGE_ROOTFS}/home/root/.ssh/ + cat ${hostsshkeysfile} >> ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys + chown root:root ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys + chmod 0600 ${IMAGE_ROOTFS}/home/root/.ssh/authorized_keys + else + echo "Could not install sshkeys from ${hostsshkeysfile}" + fi + fi +}