Add a parameter to select if sshd is started at startup

This commit is contained in:
Jacen 2018-03-18 14:42:15 +01:00
parent 4790ecd526
commit ab6e11afef
5 changed files with 27 additions and 3 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ SKIP_IMAGES
.pc .pc
*-pc *-pc
apt-cacher-ng/ apt-cacher-ng/
stage2/01-sys-tweaks/files/authorized_keys

View File

@ -101,6 +101,12 @@ The following environment variables are supported:
Add a free space in the partition (value in megabyte). If Qemu image is generated it could be usefull to have a lot of free space. Add a free space in the partition (value in megabyte). If Qemu image is generated it could be usefull to have a lot of free space.
* `USE_SSH` (Default: `"0"`)
For security SSH server is disabled by default so if you want to activate it set this to `"1"`.
If `stage2/01-sys-tweaks/files/authorized_keys` is present then it will be copied in `/root/.ssh/`
A simple example for building Raspbian: A simple example for building Raspbian:
```bash ```bash

View File

@ -140,6 +140,7 @@ export RPI_USERNAME=${RPI_USERNAME:-"pi"}
export RPI_USERPASS=${RPI_USERPASS:-"raspberry"} export RPI_USERPASS=${RPI_USERPASS:-"raspberry"}
export RPI_ROOTPASS=${RPI_ROOTPASS:-"root"} export RPI_ROOTPASS=${RPI_ROOTPASS:-"root"}
export KEYBOARD_LANG=${KEYBOARD_LANG:-"gb"} export KEYBOARD_LANG=${KEYBOARD_LANG:-"gb"}
export USE_SSH=${USE_SSH:-0}
export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"} export IMG_DATE=${IMG_DATE:-"$(date +%Y-%m-%d)"}
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

View File

@ -1,5 +1,6 @@
IMG_NAME="Raspbian" IMG_NAME="Raspbian"
USE_QEMU=1 USE_QEMU=1
USE_SSH=1
LAST_STAGE=5 LAST_STAGE=5
FREE_SPACE_MB=500 FREE_SPACE_MB=500
KEYBOARD_LANG="gb" KEYBOARD_LANG="gb"

View File

@ -15,23 +15,38 @@ on_chroot << EOF
systemctl disable hwclock.sh systemctl disable hwclock.sh
systemctl disable nfs-common systemctl disable nfs-common
systemctl disable rpcbind systemctl disable rpcbind
systemctl disable ssh
systemctl enable regenerate_ssh_host_keys systemctl enable regenerate_ssh_host_keys
EOF EOF
if [ "${USE_QEMU}" = "1" ]; then if [ "${USE_QEMU}" = "1" ]; then
echo "enter QEMU mode" log "enter QEMU mode"
install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/"
on_chroot << EOF on_chroot << EOF
systemctl disable resize2fs_once systemctl disable resize2fs_once
EOF EOF
echo "leaving QEMU mode" log "leaving QEMU mode"
else else
on_chroot << EOF on_chroot << EOF
systemctl enable resize2fs_once systemctl enable resize2fs_once
EOF EOF
fi fi
if [ "${USE_SSH}" = "1" ]; then
on_chroot << EOF
systemctl enable ssh
EOF
if [[ -e files/authorized_keys ]]; then
log "Copy authorized_keys in root ssh directory"
install -d "${ROOTFS_DIR}/root/.ssh"
install -m 644 files/authorized_keys "${ROOTFS_DIR}/root/.ssh/"
fi
else
on_chroot << EOF
systemctl disable ssh
EOF
fi
on_chroot << \EOF on_chroot << \EOF
for GRP in input spi i2c gpio; do for GRP in input spi i2c gpio; do
groupadd -f -r "$GRP" groupadd -f -r "$GRP"