Skip to content

Instantly share code, notes, and snippets.

@cyrex562
Created September 21, 2020 20:09
Show Gist options
  • Save cyrex562/07ebb2819edc4f8d29d6b26e13e7b567 to your computer and use it in GitHub Desktop.
Save cyrex562/07ebb2819edc4f8d29d6b26e13e7b567 to your computer and use it in GitHub Desktop.
Enable tcpdump for non-root users on Debian/Ubuntu.
#!/usr/bin/env bash
# NOTE: This will let anyone who belongs to the 'pcap' group
# execute 'tcpdump'
# NOTE2: User running the script MUST be a sudoer. It is
# convenient to be able to sudo without a password.
sudo groupadd pcap
sudo usermod -a -G pcap $USER
sudo chgrp pcap /usr/sbin/tcpdump
sudo setcap cap_net_raw,cap_net_admin=eip /usr/sbin/tcpdump
sudo ln -s /usr/sbin/tcpdump /usr/bin/tcpdump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment