Skip to content

Conversation

@terem42
Copy link

@terem42 terem42 commented Jan 6, 2026

This commit extends remote SSH access support for ZFSBootMenu and fixes some DHCP bugs.

New Features:

  • SSH timeout support (zbm.ssh_timeout=N): Wait N seconds for SSH login before auto-boot
  • Network readiness check before SSH timeout starts
  • Race condition prevention: Console waits when SSH user is connected
  • Dropbear SSH on port 22 (configurable)

RFC 3442 DHCP Fix:

  • Patched dhclient-script with robust parse_option_121() function
  • Fixes 'integer expression expected' and 'shift count out of range' errors
  • Works correctly with Hetzner and other providers using classless static routes
  • Uses dracut module prefix 30 to load before 35network-legacy

This commit adds comprehensive remote SSH access support for ZFSBootMenu:

New Features:
- SSH timeout support (zbm.ssh_timeout=N): Wait N seconds for SSH login before auto-boot
- Network readiness check before SSH timeout starts
- Race condition prevention: Console waits when SSH user is connected
- Dropbear SSH on port 22 (configurable)

RFC 3442 DHCP Fix:
- Patched dhclient-script with robust parse_option_121() function
- Fixes 'integer expression expected' and 'shift count out of range' errors
- Works correctly with Hetzner and other providers using classless static routes
- Uses dracut module prefix 30 to load before 35network-legacy

New Files:
- contrib/dracut-modules/30rfc3442fix/: Dracut module for dhclient-script fix
- contrib/network-hooks/dhclient-script.patched: Patched dhclient-script
- contrib/zbm-repack.sh: Standalone tool to repack EFI/BIOS images with SSH keys

Modified Files:
- contrib/remote-ssh-build.sh: Build ZBM with SSH support and DHCP fix
- zfsbootmenu/libexec/zfsbootmenu-init: SSH timeout and detection logic
- zfsbootmenu/pre-init/zfsbootmenu-parse-commandline.sh: Parse zbm.ssh_timeout
- zfsbootmenu/pre-init/zfsbootmenu-preinit.sh: Export zbm_ssh_timeout
@ahesford
Copy link
Member

ahesford commented Jan 6, 2026

Thanks for your contribution. Unfortunately, most of this work is out of scope for the project:

  1. We will not vendor other dracut modules, especially those that are orthogonal to the functions of ZFSBootMenu itself. The alternative network module should be a separate project.
  2. A script to repack the initramfs, while potentially useful for ZBM workflows, should be sufficiently general that it is not tied to ZFSBootMenu or to manipulating dropbear keys therein.
  3. The changes to zfsbootmenu-init are both too specific and tied to optional add-ons that shouldn't be a part of the core ZBM logic. (Nothing in ZFSBootMenu itself assumes the existence of an SSH server, although some of the main event loop is aware of the possibility that another instance might be running somewhere.) Furthermore, it is superfluous; if you just make the regular timeout a bit longer, you will have time to log in and start a ZFSBootMenu instance before the auto-boot logic takes effect. The auto-boot sequence should terminate if a ZBM instance is running. If it does not, this is a bug that needs to be fixed.

In addition, the contrib scripts are intended to serve as starting points for customization, and should be as general and reusable as possible. Proposed changes to the remote-ssh-build.sh would reduce the generality of the script. Users provide their own authorized_keys content; they can add a command prefix if they desire. They can also add arguments to the kernel command line to configure interfaces as they see fit, without the script imposing structure.

@ahesford ahesford closed this Jan 6, 2026
@terem42
Copy link
Author

terem42 commented Jan 6, 2026

Unfortunately, the very nature of DHCP bug in dracut and combined nature of zbm being able to be accessible simultaneosly via KVM console and SSH leave not many other choices.

Thanks for your feedback, I will keep this fork anyway, it's proved itself very useful for situations where one need to removely manage systems where KVM console is not available.

@classabbyamp
Copy link
Member

if it's a bug in dracut, make an issue/PR to https://github.com/dracut-ng/dracut-ng

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants