Created
January 20, 2020 12:32
-
-
Save cmbuckley/9a33ac88606ac34897eb79b10ebb6f07 to your computer and use it in GitHub Desktop.
Update UFW with IPs from GitHub
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
github=$(curl -s https://api.github.com/meta | jq -r '.web | .[]' | sed 's~/32~~' | sort) | |
ufw=$(ufw status | grep '# GitHub' | awk '{print $1}' | sort) | |
comm -13 <(echo "$ufw") <(echo "$github") | while read addition; do | |
echo "Adding $addition" | |
ufw allow out to $addition port 22 comment GitHub | |
done | |
comm -23 <(echo "$ufw") <(echo "$github") | while read deletion; do | |
echo "Deleting $deletion" | |
ufw delete allow out to $deletion port 22 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment