Enable ssh in both odroid-xu and xu3 scripts
Also regenerate ssh keys at first start.
This commit is contained in:
21
odroid-xu.sh
21
odroid-xu.sh
@@ -92,6 +92,21 @@ cat << EOF > kali-$architecture/etc/resolv.conf
|
||||
nameserver 8.8.8.8
|
||||
EOF
|
||||
|
||||
cat << 'EOF' > kali-$architecture/lib/systemd/system/regenerate_ssh_host_keys.service
|
||||
[Unit]
|
||||
Description=Regenerate SSH host keys
|
||||
Before=ssh.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
|
||||
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
|
||||
ExecStart=/usr/bin/ssh-keygen -A -v
|
||||
ExecStartPost=/bin/sh -c "for i in /etc/ssh/ssh_host_*_key*; do actualsize=$(wc -c <\"$i\") ;if [ $actualsize -eq 0 ]; then echo size is 0 bytes ; exit 1 ; fi ; done ; /bin/systemctl disable regenerate_ssh_host_keys"
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
chmod 644 kali-$architecture/lib/systemd/system/regenerate_ssh_host_keys.service
|
||||
|
||||
export MALLOC_CHECK_=0 # workaround for LP: #520465
|
||||
export LC_ALL=C
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
@@ -121,7 +136,6 @@ apt-get update
|
||||
apt-get -y install git-core binutils ca-certificates initramfs-tools u-boot-tools
|
||||
apt-get -y install locales console-common less nano git
|
||||
echo "root:toor" | chpasswd
|
||||
sed -i -e 's/KERNEL\!=\"eth\*|/KERNEL\!=\"/' /lib/udev/rules.d/75-persistent-net-generator.rules
|
||||
rm -f /etc/udev/rules.d/70-persistent-net.rules
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get --yes --allow-change-held-packages install $packages
|
||||
@@ -132,6 +146,11 @@ fi
|
||||
apt-get --yes --allow-change-held-packages dist-upgrade
|
||||
apt-get --yes --allow-change-held-packages autoremove
|
||||
|
||||
# Generate SSH host keys on first run
|
||||
systemctl enable regenerate_ssh_host_keys
|
||||
systemctl enable ssh
|
||||
|
||||
|
||||
rm /usr/sbin/policy-rc.d
|
||||
rm -f /usr/sbin/invoke-rc.d
|
||||
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
|
||||
|
||||
@@ -88,6 +88,22 @@ cat << EOF > kali-$architecture/etc/resolv.conf
|
||||
nameserver 8.8.8.8
|
||||
EOF
|
||||
|
||||
cat << 'EOF' > kali-$architecture/lib/systemd/system/regenerate_ssh_host_keys.service
|
||||
[Unit]
|
||||
Description=Regenerate SSH host keys
|
||||
Before=ssh.service
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
|
||||
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
|
||||
ExecStart=/usr/bin/ssh-keygen -A -v
|
||||
ExecStartPost=/bin/sh -c "for i in /etc/ssh/ssh_host_*_key*; do actualsize=$(wc -c <\"$i\") ;if [ $actualsize -eq 0 ]; then echo size is 0 bytes ; exit 1 ; fi ; done ; /bin/systemctl disable regenerate_ssh_host_keys"
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
chmod 644 kali-$architecture/lib/systemd/system/regenerate_ssh_host_keys.service
|
||||
|
||||
|
||||
export MALLOC_CHECK_=0 # workaround for LP: #520465
|
||||
export LC_ALL=C
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
@@ -117,7 +133,6 @@ apt-get update
|
||||
apt-get -y install git-core binutils ca-certificates initramfs-tools u-boot-tools
|
||||
apt-get -y install locales console-common less nano git
|
||||
echo "root:toor" | chpasswd
|
||||
sed -i -e 's/KERNEL\!=\"eth\*|/KERNEL\!=\"/' /lib/udev/rules.d/75-persistent-net-generator.rules
|
||||
rm -f /etc/udev/rules.d/70-persistent-net.rules
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get --yes --allow-change-held-packages install $packages
|
||||
@@ -128,6 +143,10 @@ fi
|
||||
apt-get --yes --allow-change-held-packages dist-upgrade
|
||||
apt-get --yes --allow-change-held-packages autoremove
|
||||
|
||||
# Generate SSH host keys on first run
|
||||
systemctl enable regenerate_ssh_host_keys
|
||||
systemctl enable ssh
|
||||
|
||||
rm /usr/sbin/policy-rc.d
|
||||
rm -f /usr/sbin/invoke-rc.d
|
||||
dpkg-divert --remove --rename /usr/sbin/invoke-rc.d
|
||||
|
||||
Reference in New Issue
Block a user