Forrest logo
back to the wg tool

wg:tldr:aba62

wg: Generate a public and private key.
$ wg genkey | tee ${path-to-private_key} | wg pubkey > ${path-to-public_key}
try on your machine

This command can be broken down into several parts:

  1. wg genkey: It runs the "genkey" command of the WireGuard utility. This command generates a WireGuard private key.

  2. |: It is a pipe symbol that connects the output of the previous command to the input of the next command.

  3. tee ${path-to-private_key}: The tee command is used to read from standard input and write to both standard output and files. In this case, it takes the output from the previous command and writes it to a file specified by ${path-to-private_key}. This file will contain the generated WireGuard private key.

  4. |: Another pipe symbol used to connect the output of the previous command to the input of the next command.

  5. wg pubkey: This command is used to derive the corresponding public key from a given WireGuard private key.

  6. > ${path-to-public_key}: This redirects the output of the wg pubkey command to a file specified by ${path-to-public_key}. This file will contain the generated WireGuard public key.

In summary, this command generates a WireGuard private key using wg genkey, saves it to a file using tee, then derives the corresponding public key using wg pubkey, and finally saves the public key to a different file.

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