Port regenerate_ssh_host_key to a systemd service
This commit is contained in:
parent
c5e4f61df2
commit
21a681692a
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash -e
|
#!/bin/bash -e
|
||||||
|
|
||||||
install -m 755 files/regenerate_ssh_host_keys ${ROOTFS_DIR}/etc/init.d/
|
install -m 644 files/regenerate_ssh_host_keys.service ${ROOTFS_DIR}/lib/systemd/system/
|
||||||
install -m 755 files/apply_noobs_os_config ${ROOTFS_DIR}/etc/init.d/
|
install -m 755 files/apply_noobs_os_config ${ROOTFS_DIR}/etc/init.d/
|
||||||
install -m 755 files/resize2fs_once ${ROOTFS_DIR}/etc/init.d/
|
install -m 755 files/resize2fs_once ${ROOTFS_DIR}/etc/init.d/
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: regenerate_ssh_host_keys
|
|
||||||
# Required-Start:
|
|
||||||
# Required-Stop:
|
|
||||||
# Default-Start: 2
|
|
||||||
# Default-Stop:
|
|
||||||
# Short-Description: Regenerate ssh host keys
|
|
||||||
# Description:
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
. /lib/lsb/init-functions
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
start)
|
|
||||||
log_daemon_msg "Regenerating ssh host keys"
|
|
||||||
nohup sh -c "if [ -e /dev/hwrng ]; then
|
|
||||||
dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
|
|
||||||
fi; \
|
|
||||||
yes | ssh-keygen -q -N '' -t dsa -f /etc/ssh/ssh_host_dsa_key && \
|
|
||||||
yes | ssh-keygen -q -N '' -t rsa -f /etc/ssh/ssh_host_rsa_key && \
|
|
||||||
yes | ssh-keygen -q -N '' -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key && \
|
|
||||||
yes | ssh-keygen -q -N '' -t ed25519 -f /etc/ssh/ssh_host_ed25519_key && \
|
|
||||||
sync && \
|
|
||||||
rm /etc/init.d/regenerate_ssh_host_keys && \
|
|
||||||
update-rc.d regenerate_ssh_host_keys remove && \
|
|
||||||
printf '\nfinished\n'" > /var/log/regen_ssh_keys.log 2>&1
|
|
||||||
log_end_msg $?
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Usage: $0 start" >&2
|
|
||||||
exit 3
|
|
||||||
;;
|
|
||||||
esac
|
|
11
stage2/01-sys-tweaks/files/regenerate_ssh_host_keys.service
Normal file
11
stage2/01-sys-tweaks/files/regenerate_ssh_host_keys.service
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Regenerate SSH host keys
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStartPre=/bin/sh -c "if [ -e /dev/hwrng ]; then dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096; fi"
|
||||||
|
ExecStart=/usr/bin/ssh-keygen -A
|
||||||
|
ExecStartPost=/bin/rm /lib/systemd/system/regenerate_ssh_host_keys.service ; /usr/sbin/update-rc.d regenerate_ssh_host_keys remove
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user