๐ก WireGuard wg CLI Sheet: Key Generation โ Executive Summary
Technical architectural analysis, practical configuration manifests, and deployment instructions for WireGuard wg CLI Sheet: Key Generation.
Installation
- Mac OS
bash
brew install wireguard-tools
- (VPN Client Tool)
Exec
help
txt
Usage: wg <cmd> [<args>]
Available subcommands:
show: Shows the current configuration and device information
showconf: Shows the current configuration of a given WireGuard interface, for use with `setconf'
set: Change the current configuration, add peers, remove peers, or change peers
setconf: Applies a configuration file to a WireGuard interface
addconf: Appends a configuration file to a WireGuard interface
syncconf: Synchronizes a configuration file to a WireGuard interface
genkey: Generates a new private key and writes it to stdout
genpsk: Generates a new preshared key and writes it to stdout
pubkey: Reads a private key from stdin and writes a public key to stdout
You may pass `--help' to any of these subcommands to view usage.
Create a client tunneling interface (Linux Only)
References and Guidelines (NOTE)
In the current CLI version, the peer’s address cannot be set in .conf, and it has been confirmed that it must be added to the tunnel configuration. wireguard-tools v1.0.20250521
- git.zx2c4.com
- It has been confirmed that the binaries below will be updated in the future
- (VPN Client Tool)
bash
# ip link ๋ช
๋ น์ผ๋ก ์ง์ ์ ์
ip link add dev wg0 type wireguard
# ํผ์ด๋ง ๋์ญ ์ถ๊ฐ
ip address add dev utun9 10.0.X.X/32
## ๋จ์ผ IP 2๊ฐ ์ถ๊ฐ
ip address add dev utun9 192.168.2.1 peer 192.168.2.2
# config ์์ฑ
myConfig="""
"""
cat <<EOF > /etc/wireguard/utun9.conf
$myConfig
EOF
# config๋ก ์ธํฐํ์ด์ค๊ตฌ์ฑ (Adderess x)
wg setconf utun9 utun9.conf
End connection
Check status
bash
sudo wg show
>>>
interface: utun6
public key: <secret>
private key: (hidden)
listening port: 57450
peer: <secret>
endpoint: <WAN_IP>:41821
allowed ips: 10.0.X.X/24, 118.37.2.0/24, 192.168.118.0/24
latest handshake: 2 minutes, 16 seconds ago
transfer: 2.98 KiB received, 14.31 GiB sent
persistent keepalive: every 25 seconds
<<<
# ๋ฆฌ์ผ ์ธํฐํ์ด์ค๋ก ์กฐํ
sudo wg showconf utun6
>>>
[Interface]
ListenPort = 57450
PrivateKey = <secret>
[Peer]
PublicKey = <secret>
AllowedIPs = 10.0.X.X/24, 118.37.2.0/24, 192.168.118.0/24
Endpoint = <WAN_IP>:41821
PersistentKeepalive = 25
<<<
Features
Generate private and public keys for peers
bash
mkdir wg-mgnt-peer1
cd wg-mgnt-peer1/
#wg genkey > privatekey
#cat privatekey
#cat privatekey | wg pubkey > publickey
#cat publickey
wg genkey | tee privatekey | wg pubkey > publickey




Leave a Reply