FZGuard
A simple tool to interactively use WireGuard with FZF.
- Published on .
- Last updated on .
- Source: https://codeberg.org/codingotaku/fzguard
About
FZGuard is a simple tool to interactively use wireguard-tools (wg
, wg-quick
) with fzf
Installation
If you are using Gentoo GNU/Linux, you can find this package in my cowaybuilds ebuild repository as app-shells/fzguard
package.
For generic linux installation, do the following.
Clone the repository
git clone https://codeberg.org/codingotaku/fzguard fzguard
cd fzguard
Install the dependencies
These can be found in your package manager of your distribution.
fzf
bash
wireguard-tools
Copy the script to the user bin folder
sudo cp fzguard /usr/bin/fzguard
# Optional, Copy the man page
sudo cp fzguard.1 /usr/share/man/man1/fzguard.1
Usage
The script needs to be run with elevated privilages as WireGuard connections cannot be established without it.
So you can either:
- As a root user, run
fzguard
in a terminal. - Run using
sudo
,doas
, or any other privilage elevation tool.
After running fzguard
, you will get an interactive interface to manage your WireGuard connections.
If your WireGuard config file is not placed under /etc/wireguard
, you can set the config path with with -p
option. e.g, sudo fzguard -p /path/to/config/directory
.
Quick management
In some cases, you may want to quickly connect or disconnect from interfaces for a faster workflow. In such scenarios, just send the command as a flag. For example:
- Connect to a new interface -
sudo fzguard -c
- Rwplace an existing connection with a new one -
sudo fzguard -r
- Disconnect to from an interface -
sudo fzguard -d
- Disconnect from from all interfaces -
sudo fzguard -a
- List all active connections -
fzguard -l
(does not require root)
For all the options except -l
, you can provide a custom WireGuard config path using -p
option with the path as the argument, for example:
# connect an interface defined in /path/to/config/directory
sudo fzguard -c -p /path/to/config/directory
# disconnect from an interface defined in /path/to/config/directory
sudo fzguard -d -p /path/to/config/directory
# replace an interface defined in /path/to/config/directory with another iterface in the same directory
sudo fzguard -r -p /path/to/config/directory
Note: It is not yet possible to replace an interface from one directory to another, suggections are welcome if this can be done in an unambiguous way.
Tip: Use an alias
if you have to always use a custom path instead of the default path (alias fwg="sudo fzguard -p /my/custom/wireguard/path"
)
Caviates
- The script has not gone through security audits, and your
fzf
configurations will interfere with the commands being executed, so use at your own risk. - As this is intented as an interactive program, the output will always have color, we may need to create a flag or configuration file for having better capability with some terminals that do not support color in the future.
If you find other issues, please create an issue or send me an e-mail.
Also, feel free to send me a patch or create a pull request for these if you can.