Commit ff66f763 authored by Paul Wolneykien's avatar Paul Wolneykien Committed by Anton Midyukov

net-ssh: Use two-pass method to install an authorized key for root

parent 0feda29c
......@@ -3,11 +3,11 @@ ifneq (,$(BUILDDIR))
include $(BUILDDIR)/distcfg.mk
# prepare the provided public SSH key to be carried over into the image
all: SSH_DIR = $(BUILDDIR)/files/root/.ssh
all: TMPDIR = $(BUILDDIR)/files/tmp
all:
@if [ -s "$(SSH_KEY)" ]; then \
mkdir -pm0700 "$(SSH_DIR)"; \
install -pm0600 "$(SSH_KEY)" "$(SSH_DIR)/authorized_keys"; \
mkdir -p "$(TMPDIR)"; \
cp -v "$(SSH_KEY)" "$(TMPDIR)/root_ssh_key.pub"; \
fi
endif
#!/bin/sh -efu
TMPDIR=/tmp
SSH_DIR=/root/.ssh
if [ -e "$TMPDIR/root_ssh_key.pub" ]; then
mkdir -pm0700 "$SSH_DIR"
install -v -pm0600 "$TMPDIR/root_ssh_key.pub" "$SSH_DIR/authorized_keys"
rm -fv "$TMPDIR/root_ssh_key.pub"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment