Improve dropbear key detection and creation #15
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is not a great idea to copy host keys into an initramfs because an initramfs is often readable by the world (and will always be so when installed on, e.g., an EFI system partition with systemd-boot). Generating keys is good for testing but is not good in production because each new initramfs will have unique keys and trigger warnings or hard failures on the client. The best option is to maintain a second set of host keys only for initramfs images, which can be stored in dropbear format in /etc/dropbear.
To allow this possibility, this PR alters the installation script to simply copy the /etc/dropbear directory of that directory contains at least one recognized key. If not, the old behavior is preserved: converting OpenSSH host keys if possible, generating new ones if not.
While we're refactoring key management, let's add (optional) support for ed25519, ignoring failures in case the version of dropbear used by the hook does not support that type.
This supersedes #13 with a cleaner implementation that doesn't break the hook with older versions of dropbear.