Script to Whitelist IPs

Hi, we have a manual task that we would like to automate. We have a web server with restricted access through a whitelist where we manually add IPs to it by following the steps below. We would like to create a script that once it's run it would prompt the user to enter the IP. One entered, the script takes care of the rest. Your help is very appreciated. Thank you

  • ssh to server root@x.x.x.x
  • Login as user by typing su - user
  • vi /a/b/c/xx.conf (xx.conf is a file with a list of whitelisted IPs in the following format)
Allow from x.x.x.x
Allow from x.x.y.y
Allow from x.x.z.z
</ProxyMatch>
  • Press ctrl E to Edit the file
  • Press i to insert
  • Add new IP to the file
  • Press Escape then type :wq
  • sudo su
  • service httpd reload

Thank you

Hi,

the typical questions:

  • What are your operating systems?
  • What have you tried so far?

For a start, write a script maybe with awk or sed which does the change on the server for you locally!

Regards,
stomp

Hi Community, anyone can help with this?

Thanks

Please answer the previously asked questions.