Skip to content

Instantly share code, notes, and snippets.

@pjobson
Last active March 19, 2024 19:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pjobson/2f4979e7570f4f3f9a34e42f5617488a to your computer and use it in GitHub Desktop.
Save pjobson/2f4979e7570f4f3f9a34e42f5617488a to your computer and use it in GitHub Desktop.
Remove USB Guard From Ubuntu

Remove USB Guard From Ubuntu

If you're a sucker like me and installed usbguard on a Ubuntu variant you may find that you will have access to none of your usb devices at all, because F you. The installer automatically sets up the daemon which has no rules so will just block all of your devices. Doing a basic apt remove usbguard may fail at 25%, because also F you.

My kernel is version 4.15.0-47-generic, not sure if this stopped working at some point or what.

Regain Access

sudo echo "allow id *:*" > /etc/usbguard/rules.conf
sudo sed -i 's/PresentDevicePolicy=apply-policy/PresentDevicePolicy=allow/' /etc/usbguard/usbguard-daemon.conf
sudo reboot

Reboot may hang at stopping usbguard, again, because F you. Power off or wait. You'll hopefully have access to your devices when your machine comes back up.

Stop & Disable Services

sudo systemctl stop usbguard.service
sudo systemctl disable usbguard.service
sudo systemctl stop usbguard-dbus.service
sudo systemctl disable usbguard-dbus.service

Uninstall and Purge

sudo apt remove usbguard -y
sudo apt purge usbguard -y

Remove Conf Files

sudo rm -rf /etc/usbguard/

Reboot

I had issues until I rebooted for whatever reason.

 sudo reboot

Now you're free!

@delton137
Copy link

delton137 commented Nov 10, 2020

What if you can't access your system even through Safe Mode? That's what I'm dealing right now. I'm so mad and angry at whatever dumbass developer is responsible for this.

I am trying to boot via a USB and see if I can remove it from the filesystem somehow

@delton137
Copy link

delton137 commented Nov 10, 2020

I had to chroot into the installation from a live installation running off a USB stick and then follow your instructions !! What a pain!!
I used the instructions here to figure out how to chroot:
https://superuser.com/questions/111152/whats-the-proper-way-to-prepare-chroot-to-recover-a-broken-linux-installation

@pjobson
Copy link
Author

pjobson commented Nov 10, 2020

@delton137 reboot into single user mode or boot off of a live USB.

Either way, you'll have to mount your system's drive read/write to modify it. Hit me up if you need help messing around with it.

@pjobson
Copy link
Author

pjobson commented Nov 10, 2020

Thanks for the follow-up, looks like I responded slightly after you did.

@delton137
Copy link

thank you , and thanks for proving the instructions. It was necessary to use apt-get purge to fully remove it, which is not obvious.

@mwillson82
Copy link

man, you captured my sentiments to the T. Did this on a raspberry pi so had to take sd card out, put in usb adapter behind my machine on a usb-c port, and crawl my fat ass back out 2x. I kept the install and fixed it once back in tho, well see how that turns out :D

Good fucking day to us all

@boomshadow
Copy link

This article talks about the hilariousness of the problem, but also details a safe way to install USBGuard by first disabling systemd's ability to start the service: https://roussos.cc/2019/08/19/usbguard/

TL;DR Run sudo ln -s /dev/null /etc/systemd/system/usbguard.service before installing USBGuard from apt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment