summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--setup-alpine.in7
-rwxr-xr-xtests/setup_alpine_test10
2 files changed, 12 insertions, 5 deletions
diff --git a/setup-alpine.in b/setup-alpine.in
index 50de2f1..99692cf 100644
--- a/setup-alpine.in
+++ b/setup-alpine.in
@@ -113,10 +113,13 @@ if [ -n "$CREATEANSWERFILE" ]; then
# Create admin user
USEROPTS="-a -u -g audio,video,netdev juser"
- USERSSHKEY="https://example.com/juser.keys"
+ #USERSSHKEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIiHcbg/7ytfLFHUNLRgEAubFz/13SwXBOM/05GNZe4 juser@examle.com"
+ #USERSSHKEY="https://example.com/juser.keys"
# Install Openssh
SSHDOPTS=openssh
+ #ROOTSSHKEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOIiHcbg/7ytfLFHUNLRgEAubFz/13SwXBOM/05GNZe4 juser@examle.com"
+ #ROOTSSHKEY="https://example.com/juser.keys"
# Use openntpd
# NTPOPTS="openntpd"
@@ -238,7 +241,7 @@ for i in "$ROOT"home/*; do
fi
done
-setup-sshd ${SSHDOPTS}
+setup-sshd ${ROOTSSHKEY+-k "$ROOTSSHKEY"} ${SSHDOPTS}
root_keys="$ROOT"/root/.ssh/authorized_keys
if [ -f "$root_keys" ]; then
lbu add "$root_keys"
diff --git a/tests/setup_alpine_test b/tests/setup_alpine_test
index 4b26a5d..7d008e0 100755
--- a/tests/setup_alpine_test
+++ b/tests/setup_alpine_test
@@ -34,20 +34,24 @@ setup_alpine_create_answerfile_body() {
mkdir -p usr/share/zoneinfo/
touch usr/share/zoneinfo/UTC
- sed -i -e 's/^USERSSHKEY=.*/USERSSHKEY="ssh-rsa blahbla user@example.com"/' \
- answers
+ echo 'USERSSHKEY="ssh-rsa blahbla user@example.com"/' >> answers
+ echo 'ROOTSSHKEY="ssh-rsa blahbla user@example.com"' >> answers
atf_check -s exit:0 \
-o match:"Starting hostname" \
-o match:"Starting mdev" \
-o match:"Added mirror" \
-o match:"adduser" \
- -o match:"apk add" \
+ -o match:"apk add.*openssh" \
setup-alpine -f answers
grep "ssh-rsa blahbla user@example.com" home/juser/.ssh/authorized_keys \
|| atf_fail "ssh key not set for juser"
+ grep "ssh-rsa blahbla user@example.com" root/.ssh/authorized_keys \
+ || atf_fail "ssh key not set for root"
grep home/juser etc/apk/protected_paths.d/lbu.list \
|| atf_fail "home/juser was not added to lbu.list"
+ grep root/.ssh etc/apk/protected_paths.d/lbu.list \
+ || atf_fail "root/.ssh was not added to lbu.list"
}
setup_alpine_kvm_clock_body() {