File tree Expand file tree Collapse file tree 4 files changed +39
-1
lines changed
files/regenerate_ssh_host_keys Expand file tree Collapse file tree 4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -7,3 +7,19 @@ source /common.sh
7
7
install_cleanup_trap
8
8
9
9
apt-get install --yes --reinstall raspberrypi-bootloader raspberrypi-kernel
10
+
11
+ kernel_version=$(dpkg -s raspberrypi-kernel | grep -i version | awk '{print $2}')
12
+ if [ "$kernel_version" = "1:1.20230317-1" ]; then
13
+ # This kernel version needs a workaround because ssh key generation is slow AF
14
+ #
15
+ # Patches from https://github.com/RPi-Distro/pi-gen/issues/682#issuecomment-1484119300
16
+ #
17
+ # Note that this is a temporary workaround, and will be removed in the future. Using
18
+ # /dev/urandom instead of /dev/hwrng is less secure for key generation, however for now
19
+ # it is the only way to get a working system thanks to a kernel bug in hwrng on anything
20
+ # other than the Pi 4, see https://github.com/raspberrypi/linux/issues/5390
21
+ pushd /
22
+ patch -p1 -u -b < /files/regenerate_ssh_host_keys/regenerate_ssh_host_keys.patch
23
+ patch -p1 -u -b < /files/regenerate_ssh_host_keys/firstboot.patch
24
+ popd
25
+ fi
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ install_cleanup_trap
10
10
[ -f '/root/bin/user-fix' ] && exit 0
11
11
12
12
# we need to install virtualenv-tools3, so let's get pip and that
13
- apt install -y python3-pip
13
+ apt-get install -y python3-pip
14
14
sudo -u pi pip3 install --user virtualenv-tools3
15
15
16
16
cp /files/user-fix /root/bin/user-fix
Original file line number Diff line number Diff line change
1
+ --- a/usr/lib/raspberrypi-sys-mods/firstboot 2022-09-15 13:46:12.000000000 +0100
2
+ +++ b/usr/lib/raspberrypi-sys-mods/firstboot 2023-03-28 12:31:05.529858256 +0100
3
+ @@ -63,7 +63,7 @@
4
+ fix_partuuid() {
5
+ mount -o remount,rw "$ROOT_PART_DEV"
6
+ mount -o remount,rw "$BOOT_PART_DEV"
7
+ - DISKID="$(tr -dc 'a-f0-9' < /dev/hwrng | dd bs=1 count=8 2>/dev/null)"
8
+ + DISKID="$(tr -dc 'a-f0-9' < /dev/urandom | dd bs=1 count=8 2>/dev/null)"
9
+ fdisk "$ROOT_DEV" > /dev/null <<EOF
10
+ x
11
+ i
Original file line number Diff line number Diff line change
1
+ --- a/usr/lib/raspberrypi-sys-mods/regenerate_ssh_host_keys 2022-09-01 16:22:09.000000000 +0100
2
+ +++ b/usr/lib/raspberrypi-sys-mods/regenerate_ssh_host_keys 2023-03-28 12:26:26.822217883 +0100
3
+ @@ -1,8 +1,5 @@
4
+ #!/bin/sh -e
5
+
6
+ - if [ -c /dev/hwrng ]; then
7
+ - dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096 status=none
8
+ - fi
9
+ rm -f /etc/ssh/ssh_host_*_key*
10
+ ssh-keygen -A > /dev/null
11
+ systemctl -q disable regenerate_ssh_host_keys
You can’t perform that action at this time.
0 commit comments