r/WireGuard • u/mmguero • Oct 08 '20
a wireguard bash script for wg/wg-quick/systemctl; supports encrypting/decrypting/using openssl-encrypted wireguard config files with wg-quick up and down
https://gist.github.com/mmguero/53f4c9c04ac49c330800e463e4620808
17
Upvotes
3
u/mmguero Oct 08 '20 edited Oct 08 '20
I thought I'd share this little bash script I'm using to keep some of my wireguard configuration files encrypted.
The idea is you create your wireguard config file (eg,
wg0.conf), then runwwg.sh enc wg0.confto encrypt it. Then, you can usewwg.sh up wg0.confwhich will temporarily decrypt the file, runwg-quick upfor that interface with the decrypted config file, then shred it so the plaintext version doesn't remain on disk for longer than the time thewg-quickoperation takes.Operations include:
up- runwg-quick up(detects and handles encrypted configuration files)down- runwg-quick downenc- encrypt a config filedec- decrypt a config file (e.g., for when you need to make edits to it)show- runwg show(don't confuse withstatus)status- runsystemctl status wg-quick@XXX.serviceenable- runsystemctl enable wg-quick@XXX.servicedisable- runsystemctl enable wg-quick@XXX.servicestart- runsystemctl start wg-quick@XXX.service(don't confuse withup; doesn't handle encrypted configuration files)stop- runsystemctl stop wg-quick@XXX.service(don't confuse withdown)I'm running this on Debian 10. Your mileage may vary, no support provided, it's not my fault if it borks your machine, yada yada disclaimer yada, etc.
EDIT: I didn't mention,
opensslis required for file encryption/decryption.opensslwill prompt you at the command line for the password when needed, so this script requires an interactive shell.2
u/plosie Oct 08 '20
Shred will not work on ssd storage, correct?
3
u/Ikebook89 Oct 08 '20
So wireguard can’t Autostart after reboot? What’s the point or advantage of an encrypted wg0.conf?
1
u/NatLife Oct 09 '20
great job man thanks a lot 🙏🏻
1
u/its0x08 Oct 09 '20
https://github.com/its0x08/wg-install
1
u/decaby7e Oct 09 '20
Will say this script is absolutely beautiful! Saving for use with Wireguard but also as inspiration for my own scripts 😄
0
u/[deleted] Oct 10 '20
[deleted] — view deleted comment