Forrest logo
back to the wg tool

wg:tldr:a9b38

wg: Generate a public key from a private key.
$ wg pubkey < ${path-to-private_key} > ${path-to-public_key}
try on your machine

The command "wg pubkey < ${path-to-private_key} > ${path-to-public_key}" is used to generate a WireGuard public key from a corresponding private key.

Here is a breakdown of the command:

  1. "wg pubkey": This is the WireGuard command used to generate the public key.

  2. "< ${path-to-private_key}": The "<" symbol is used for input redirection, and "${path-to-private_key}" represents the path to your private key file. This part of the command redirects the content of the private key file as input for the "wg pubkey" command.

  3. "> ${path-to-public_key}": The ">" symbol is used for output redirection, and "${path-to-public_key}" represents the path where you want to save the public key. This part of the command redirects the output generated by the "wg pubkey" command and saves it into the specified file as the public key.

In summary, the command takes the private key file as input, uses the "wg pubkey" command to generate the public key, and saves it to the specified location.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the wg tool