This seems to work, maybe: openssl genpkey -algorithm X25519 -outform der | tail -c 32 | base64 openssl genpkey -algorithm X25519 -outform der | tail -c 32 | base64 | wg pubkey I haven't verified what's happening in the code though, so use at your own risk. wg(8) is the best way to generate wireguard private keys for use with wireguard.