Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using APT to generate SSH host keys #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AndrewKvalheim
Copy link
Member

Techniques that leverage the openssh-server package’s postinst script risk two conflicts:

  • When ssh.service has been started by APT, attempting to trigger the postinst script by starting another instance of APT deadlocks.

  • When ssh.service has been started manually, the postinst run via ssh-hostkey-generate.service causes the proximal activation of ssh.service to be canceled, and e.g. Ansible tasks to fail.

To avoid these complications, invoke ssh-keygen directly. The -A option does exactly what we need:

Generate host keys of all default key types (rsa, ecdsa, and ed25519) if they do not already exist.

Techniques that leverage the openssh-server package’s postinst script
risk two conflicts:

  - When ssh.service has been started by APT, attempting to trigger the
    postinst script by starting another instance of APT deadlocks.

  - When ssh.service has been started manually, the postinst script in
    the unit dependency causes the proximal activation to be canceled.

To avoid these complications, invoke ssh-keygen directly. The -A option
does exactly what we need:

> Generate host keys of all default key types (rsa, ecdsa, and ed25519)
> if they do not already exist.
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.

1 participant