mirror of
https://github.com/pivpn/pivpn.git
synced 2024-12-18 19:00:15 +00:00
Save pre-shared key to file instead of variable.
This commit is contained in:
parent
e643acce17
commit
bdfb8f4a64
2 changed files with 4 additions and 3 deletions
|
@ -75,7 +75,7 @@ if [ -f "configs/${CLIENT_NAME}.conf" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
wg genkey | tee "keys/${CLIENT_NAME}_priv" | wg pubkey > "keys/${CLIENT_NAME}_pub"
|
wg genkey | tee "keys/${CLIENT_NAME}_priv" | wg pubkey > "keys/${CLIENT_NAME}_pub"
|
||||||
CLIENT_PRE_SHARED_KEY=$(wg genpsk)
|
wg genpsk | tee "keys/${CLIENT_NAME}_psk" &> /dev/null
|
||||||
echo "::: Client Keys generated"
|
echo "::: Client Keys generated"
|
||||||
|
|
||||||
# Find an unused number for the last octet of the client IP
|
# Find an unused number for the last octet of the client IP
|
||||||
|
@ -103,7 +103,7 @@ echo >> "configs/${CLIENT_NAME}.conf"
|
||||||
|
|
||||||
echo "[Peer]
|
echo "[Peer]
|
||||||
PublicKey = $(cat keys/server_pub)
|
PublicKey = $(cat keys/server_pub)
|
||||||
PresharedKey = ${CLIENT_PRE_SHARED_KEY}
|
PresharedKey = $(cat "keys/${CLIENT_NAME}_psk")
|
||||||
Endpoint = ${pivpnHOST}:${pivpnPORT}
|
Endpoint = ${pivpnHOST}:${pivpnPORT}
|
||||||
AllowedIPs = 0.0.0.0/0, ::0/0" >> "configs/${CLIENT_NAME}.conf"
|
AllowedIPs = 0.0.0.0/0, ::0/0" >> "configs/${CLIENT_NAME}.conf"
|
||||||
echo "::: Client config generated"
|
echo "::: Client config generated"
|
||||||
|
@ -111,7 +111,7 @@ echo "::: Client config generated"
|
||||||
echo "# begin ${CLIENT_NAME}
|
echo "# begin ${CLIENT_NAME}
|
||||||
[Peer]
|
[Peer]
|
||||||
PublicKey = $(cat "keys/${CLIENT_NAME}_pub")
|
PublicKey = $(cat "keys/${CLIENT_NAME}_pub")
|
||||||
PresharedKey = ${CLIENT_PRE_SHARED_KEY}
|
PresharedKey = $(cat "keys/${CLIENT_NAME}_psk")
|
||||||
AllowedIPs = ${NET_REDUCED}.${COUNT}/32
|
AllowedIPs = ${NET_REDUCED}.${COUNT}/32
|
||||||
# end ${CLIENT_NAME}" >> wg0.conf
|
# end ${CLIENT_NAME}" >> wg0.conf
|
||||||
echo "::: Updated server config"
|
echo "::: Updated server config"
|
||||||
|
|
|
@ -91,6 +91,7 @@ for CLIENT_NAME in "${CLIENTS_TO_REMOVE[@]}"; do
|
||||||
|
|
||||||
rm "keys/${CLIENT_NAME}_priv"
|
rm "keys/${CLIENT_NAME}_priv"
|
||||||
rm "keys/${CLIENT_NAME}_pub"
|
rm "keys/${CLIENT_NAME}_pub"
|
||||||
|
rm "keys/${CLIENT_NAME}_psk"
|
||||||
echo "::: Client Keys for ${CLIENT_NAME} removed"
|
echo "::: Client Keys for ${CLIENT_NAME} removed"
|
||||||
|
|
||||||
# Find all .conf files in the home folder of the user matching the checksum of the
|
# Find all .conf files in the home folder of the user matching the checksum of the
|
||||||
|
|
Loading…
Reference in a new issue