diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-02-07 12:14:39 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-02-07 12:34:41 +0000 |
commit | 2a38709e3eb2b366c08e0aa5becc5a259eb903f3 (patch) | |
tree | 00d4f11f28dcf2b4726af9995e527f8fc99c08c4 | |
parent | 62e0fd677deaee62b1b97d17c4a4c1ea8ea311eb (diff) | |
download | morphs-2a38709e3eb2b366c08e0aa5becc5a259eb903f3.tar.gz |
Add configure extension to add an SSH public key to root account
This is necessary to implement automated tests of deployments.
-rwxr-xr-x | root-ssh-authorized-key.configure | 42 |
1 files changed, 42 insertions, 0 deletions
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" |