mirror of
/repos/baseimage-docker.git
synced 2026-02-27 17:41:59 +01:00
Disable the insecure SSH key by default
This commit is contained in:
17
image/enable_insecure_key
Executable file
17
image/enable_insecure_key
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
AUTHORIZED_KEYS=/root/.ssh/authorized_keys
|
||||
|
||||
if [[ -e "$AUTHORIZED_KEYS" ]] && grep -q baseimage-docker-insecure-key "$AUTHORIZED_KEYS"; then
|
||||
echo "Insecure key has already been added to $AUTHORIZED_KEYS."
|
||||
else
|
||||
DIR=`dirname "$AUTHORIZED_KEYS"`
|
||||
echo "Creating directory $DIR..."
|
||||
mkdir -p "$DIR"
|
||||
chmod 700 "$DIR"
|
||||
chown root:root "$DIR"
|
||||
echo "Editing $AUTHORIZED_KEYS..."
|
||||
cat /etc/insecure_key.pub > "$AUTHORIZED_KEYS"
|
||||
echo "Success: insecure key has been added to $AUTHORIZED_KEYS"
|
||||
fi
|
||||
@@ -28,7 +28,10 @@ cp /build/00_regen_ssh_host_keys.sh /etc/my_init.d/
|
||||
mkdir -p /root/.ssh
|
||||
chmod 700 /root/.ssh
|
||||
chown root:root /root/.ssh
|
||||
cat /build/insecure_key.pub > /root/.ssh/authorized_keys
|
||||
cp /build/insecure_key.pub /etc/insecure_key.pub
|
||||
chmod 644 /etc/insecure_key.pub
|
||||
chown root:root /etc/insecure_key.pub
|
||||
cp /build/enable_insecure_key /usr/sbin/
|
||||
|
||||
## Install cron daemon.
|
||||
$minimal_apt_get_install cron
|
||||
|
||||
Reference in New Issue
Block a user