Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Systemd unit to generate missing ssh keys on boot
[Unit]
Description=Generate sshd keys
Before=ssh.server
[Service]
Type=oneshot
ExecStart=/usr/bin/ssh-keygen -A
RemainAfterExit=true
StandardOutput=journal
[Install]
WantedBy=multi-user.target
@TimJDFletcher
Copy link
Author

TimJDFletcher commented May 13, 2017

Intended for installing pre-imaging on Linux systems to generate fresh keys on first boot.

Copy to /etc/systemd/system/ssh-keygen.service
Enable with systemctl enable ssh-keygen.service

@ambakshi
Copy link

ambakshi commented Aug 6, 2020

That should be Before=ssh.service , not ssh.server

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