Skip to content

Instantly share code, notes, and snippets.

@dadatuputi
Created May 16, 2020 22:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadatuputi/f317da04771603f205d6b26921146224 to your computer and use it in GitHub Desktop.
Save dadatuputi/f317da04771603f205d6b26921146224 to your computer and use it in GitHub Desktop.
EdgeOS script to enable or disable access to webui or ssh / useful with task-schedule
#!/bin/vbash
# From https://wiki.vyos.net/wiki/Configuration_scripting
# Check for correct group
if [ "$(id -g -n)" != 'vyattacfg' ] ; then
echo "switching to vyattacfg group"
exec sg vyattacfg -c "/bin/vbash $(readlink -f $0) $@"
exit 0
fi
source /opt/vyatta/etc/functions/script-template
case "$1" in
"disable")
configure
delete service gui
delete service ssh
commit
save
;;
"enable")
configure
set service gui https-port 443
set service gui older-ciphers disable
set service ssh port 22
set service ssh protocol-version v2
commit
;;
esac
@dadatuputi
Copy link
Author

dadatuputi commented May 16, 2020

From a config prompt, create two tasks like so:

task disableaccess {
     crontab-spec "0 20 * * *"
     executable {
         arguments disable
         path /config/scripts/access.sh
     }
 }
 task enableaccess {
     crontab-spec "0 5 * * *"
     executable {
         arguments enable
         path /config/scripts/access.sh
     }
 }

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