PiShrink
PiShrink copied to clipboard
Activate service to regenerate ssh host keys after said keys cleanup
When PiShrink removes the hosts keys from the image, the said keys are not regenerated on the following first boot. The ssh service will then not be available, since there are no host keys.
One way to solve the problem would be to activate the regenerate_ssh_host_keys systemd service provided by Raspberry OS.
This could be done in the mounted filesystem by creating the following symlink:
sudo ln -s /lib/systemd/system/regenerate_ssh_host_keys.service etc/systemd/system/multi-user.target.wants/regenerate_ssh_host_keys.service.
I think #73 was linked to this issue.
+1 on this. It renders a headless pi inaccessible. If you run the script without -p it does not accept the correct password.
When PiShrink removes the hosts keys from the image, the said keys are not regenerated on the following first boot. The ssh service will then not be available, since there are no host keys.
I can confirm. When i use pishrink with parameter -p, the ssh will not start when i use the image in further time. To get the ssh service back, i use raspi-config to enable it again, but that's a fool solution ;-)
When PiShrink removes the hosts keys from the image, the said keys are not regenerated on the following first boot. The ssh service will then not be available, since there are no host keys.
One way to solve the problem would be to activate the
regenerate_ssh_host_keyssystemd service provided by Raspberry OS.This could be done in the mounted filesystem by creating the following symlink:
sudo ln -s /lib/systemd/system/regenerate_ssh_host_keys.service etc/systemd/system/multi-user.target.wants/regenerate_ssh_host_keys.service.I think #73 was linked to this issue.
Not sure what the status of this repo is, but I implemented your idea in a pull request. I tested it on the latest bullseye image and it works great! https://github.com/Drewsif/PiShrink/pull/244
currently working on a revision for non-raspbian OS images and possibly support for dropbear, cause why not
Not sure what the status of this repo is,
Last commit is from 8/16/2021. As far as I can see it's no longer maintained.
Still alive, just focused on other things. Will eventually review your PR, I do appreciate the contribution though.
I don't like the way cleanup is currently done and am looking into better options