FZGuard

A simple tool to interactively use WireGuard with FZF.


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:

  1. As a root user, run fzguard in a terminal.
  2. 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

  1. 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.
  2. 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.


Mentions

Looking for comments? This website uses webmention instead, the standard way for websites to talk to each other, you can either send me one through your website, or use the below form to submit your mention. If you do not own a website, send me an email instead.

Toggle the webmention form
All webmentions will be held for moderation by me before publishing it.

About me

Coding Otaku Logo

I'm Rahul Sivananda (he/him), the Internet knows me by the name Coding Otaku (they/them). I used to work as a Full-Stack Developer in London, now actively looking for a job after being laid off.

I care about Accessibility, Minimalism, and good User Experiences. I create small tools and scripts to make the life easy. If you need help or support with GNU/Linux system, or making your website accessible, you can reach out to me!

Following me

Subscribe to my web feeds if you like what I post and want to read them without visiting this website!

You can also find me on Mastodon, Codeberg, or Peertube.

Get my cURL card with curl -sL https://codingotaku.com/cc.

Supporting me

If you would like to help me to keep this site and my silly projects running, you can now donate to me through Liberapay or Stripe

Continue Reading

Like this post? there's more where that came from! Continue reading.

Recent Projects

Subscribe via Atom or JSON feeds.