From e9afcdaed48aad39dcd247dc9301fa6b675fbf06 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 7 Feb 2014 12:14:39 +0000 Subject: Add configure extension to add an SSH public key to root account This is necessary to implement automated tests of deployments. --- root-ssh-authorized-key.configure | 42 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 root-ssh-authorized-key.configure diff --git a/root-ssh-authorized-key.configure b/root-ssh-authorized-key.configure new file mode 100755 index 0000000..7c41218 --- /dev/null +++ b/root-ssh-authorized-key.configure @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright (C) 2014 Codethink Limited +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# This is a "morph deploy" configuration extension to add an SSH key as +# an authorized key for the root account. This means that SSH access to +# the machine as root is possible as soon as the machine boots, instead +# of requiring an initial manual login. This functionality is used by +# Baserock's automated tests. +# +# The following configuration variable should point at a file +# containing an SSH public key: ROOT_SSH_PUBKEY + +set -eu + +OS="$1" + +echo "Add SSH public key for root user" + +# We don't use 'ssh-copy-id' because it requires the machine to be +# running and available over SSH already. Luckily the manual case is +# simple. +mkdir -p "$OS/root/.ssh" + +target="$OS/root/.ssh/authorized_keys" + +echo "# Added by Baserock root-ssh-authorized-key.configure" >> "$target" +cat "$ROOT_SSH_PUBKEY" >> "$target" +echo >> "$target" -- cgit v1.2.1