wg-quick linux: Add strip-and-eval cmd to extract keys from PostUp #3
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.
I will also submit this to the mailing list. I just open a PR here because I find it easier to get an overview what has been merged and what not.
Note that the patchset is incomplete (currently only for Linux). I don’t have all the other OSes laying around.
The manpage mentions the trick to use PostUp to read the PrivateKey (or PresharedKey) from a command (or file). However, when you actually use that you notice that this is currently not fully supported. The issue is that
wg syncconf wgnet0 <(wg-quick strip wgnet0)
from the manpage now breaks the VPN because it removes the private key from the WireGuard interface. The reason is that
strip
removes PostUp of course.This patch tries to add full support to read WireGuard keys from files or command outputs by evaluating PostUp using a best effort approach (using regex). It will not work for everything but when you follow the manpage closely, it will work.
I also propose to update the systemd template to make seamless use of this. This is not a must because the sysadmin can easily change the ExecReload using systemd drop-in files.
Example use of this patch: https://github.com/ypid/ansible-wireguard/tree/prepare-for-debops