I use ufw (Uncomplicated Firewall) on my web server. Right now I have it set up to allow SSH to the world and fail2ban to prevent massive sign in attempts. The web server has ports 80 and 443 open.
What I would like to do is close SSH access until I need it and then only make it available to my current public IP address that changes periodically. I am thinking of a PHP script over HTTPS that verifies my access and then puts the request into a database. Then a cron job runs a script that reads the database and runs ufw to open the SSH port for just my IP address. After 30 minutes, the rule would be removed and SSH would become inaccessible again. I also want to allow multiple IPs to have temporary access as well and I eventually want to expand to other ports beyond SSH.
What ufw commands should my aforementioned automated scripts run to temporarily add and remove SSH port access for individual IP addresses?