Generate SSH host key on first boot
This commit is contained in:
parent
82e6fdf194
commit
2d315fdf26
|
@ -29,11 +29,6 @@ cp -a "$BUILDROOT_DIR/output/images/rootfs.cpio.uboot" "$SDCARD_DIR"
|
||||||
# Wrap U-Boot script in image file
|
# Wrap U-Boot script in image file
|
||||||
$MKIMAGE -A arm -T script -d config/uboot_script.txt "$SDCARD_DIR/boot.scr"
|
$MKIMAGE -A arm -T script -d config/uboot_script.txt "$SDCARD_DIR/boot.scr"
|
||||||
|
|
||||||
# Create SSH host key for embedded system
|
|
||||||
if [ ! -f "$SDCARD_DIR/dropbear_ed25519_host_key" ]; then
|
|
||||||
dropbearkey -t ed25519 -f "$SDCARD_DIR/dropbear_ed25519_host_key"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Copy FPGA firmware
|
# Copy FPGA firmware
|
||||||
cp -a $FIRMWARE_FILES "$SDCARD_DIR"
|
cp -a $FIRMWARE_FILES "$SDCARD_DIR"
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
# Load SSH host key from SD card.
|
# Load SSH host key from SD card.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
. /opt/puzzlefw/lib/functions.sh
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
|
|
||||||
# If host key exists, do nothing.
|
# If host key exists, do nothing.
|
||||||
|
@ -14,20 +16,15 @@ start() {
|
||||||
# Create directory /etc/dropbear if it does not exist.
|
# Create directory /etc/dropbear if it does not exist.
|
||||||
mkdir -p /etc/dropbear
|
mkdir -p /etc/dropbear
|
||||||
|
|
||||||
# Try to copy SSH host key from SD card.
|
# Try to copy SSH host key from configuration files.
|
||||||
mkdir -p /mnt/tmp_sdcard
|
if ! cp -p ${CONFIG_DIR}/dropbear_ed25519_host_key /etc/dropbear ; then
|
||||||
mount -t vfat -o fmask=0177 -r /dev/mmcblk0p1 /mnt/tmp_sdcard
|
|
||||||
|
|
||||||
if ! cp -p /mnt/tmp_sdcard/dropbear_ed25519_host_key /etc/dropbear ; then
|
|
||||||
echo "WARNING: Failed to load SSH host key from SD card" >&2
|
echo "WARNING: Failed to load SSH host key from SD card" >&2
|
||||||
umount /mnt/tmp_sdcard
|
echo "Generating new SSH host key." >&2
|
||||||
rmdir /mnt/tmp_sdcard
|
dropbearkey -t ed25519 -f ${CONFIG_DIR}/dropbear_ed25519_host_key.new
|
||||||
exit 1
|
sync_config dropbear_ed25519_host_key
|
||||||
|
cp -p ${CONFIG_DIR}/dropbear_ed25519_host_key /etc/dropbear
|
||||||
fi
|
fi
|
||||||
|
|
||||||
umount /mnt/tmp_sdcard
|
|
||||||
rmdir /mnt/tmp_sdcard
|
|
||||||
|
|
||||||
chmod 0600 /etc/dropbear/dropbear_ed25519_host_key
|
chmod 0600 /etc/dropbear/dropbear_ed25519_host_key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,8 @@ read_config() {
|
||||||
mount -t ext4 -r -o noatime,data=journal /dev/${CONFIG_PARTITION} $CONFIG_MOUNTPOINT || return 1
|
mount -t ext4 -r -o noatime,data=journal /dev/${CONFIG_PARTITION} $CONFIG_MOUNTPOINT || return 1
|
||||||
|
|
||||||
# Copy config files to RAM filesystem.
|
# Copy config files to RAM filesystem.
|
||||||
cp -a ${CONFIG_MOUNTPOINT}/*.conf $CONFIG_DIR
|
cp -a ${CONFIG_MOUNTPOINT}/*.conf $CONFIG_DIR || true
|
||||||
|
cp -a ${CONFIG_MOUNTPOINT}/dropbear_* $CONFIG_DIR || true
|
||||||
|
|
||||||
umount $CONFIG_MOUNTPOINT
|
umount $CONFIG_MOUNTPOINT
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue