Last active
May 16, 2020 22:41
-
-
Save dadatuputi/5a1108791cc28c16e39213547d7ed8e8 to your computer and use it in GitHub Desktop.
Proxmox access lockout script - lock out access to webui/SSH, best used with crontab schedule
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
#!/usr/bin/env bash | |
file=/etc/pve/firewall/cluster.fw | |
drop_rule="IN DROP -log nolog" | |
group_rule="IN ACCEPT -source 192.168.1.0\/24 -log nolog" | |
function comment { | |
replace "$1" "|$1" $2 | |
} | |
function uncomment { | |
replace "|$1" "$1" $2 | |
} | |
function replace { | |
eval "sed -i '/^$1/ c$2' $3" | |
} | |
case "$1" in | |
"disable") | |
uncomment "$drop_rule" "$file" | |
comment "$group_rule" "$file" | |
;; | |
"enable") | |
comment "$drop_rule" "$file" | |
uncomment "$group_rule" "$file" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set up a crontab entry by entering
crontab -e
and adding the following lines: