I'm playing around with coding a tool to control SSHd access via scripted processing of IPs from logs and stuffing them into /etc/hosts.deny. (yes I know other tools already can do this, I'm forcing my self to think on my own as a coding exercise with some spare time...)
This is on a remote linux server and SSH is my only console access. Obviously I don't want an erroneous value to lock me out. So....
I'd like to have a simple PHP script on my Apache that I can call (e.g. hostname.tld/resethostsdeny.php), that would either delete or rename the /etc/hosts.deny file.
Obvious trouble is that this file is perm 644 and owned by user 'root'. I don't want to escalate my Apache's user to become root just to delete/rename this file.
Would you advise that PHP could tell 'cron' to do something directly? Use PHP to write a flag file that a cron job would periodically check as a flag to remove hosts.deny?
This is kind of an exercise to have an unprivileged process (apache) tell the system to act on a privileged file.
How would you do it? Thanks! Dave.
D.E.R. Management - IT Project Management Consulting
This is on a remote linux server and SSH is my only console access. Obviously I don't want an erroneous value to lock me out. So....
I'd like to have a simple PHP script on my Apache that I can call (e.g. hostname.tld/resethostsdeny.php), that would either delete or rename the /etc/hosts.deny file.
Obvious trouble is that this file is perm 644 and owned by user 'root'. I don't want to escalate my Apache's user to become root just to delete/rename this file.
Would you advise that PHP could tell 'cron' to do something directly? Use PHP to write a flag file that a cron job would periodically check as a flag to remove hosts.deny?
This is kind of an exercise to have an unprivileged process (apache) tell the system to act on a privileged file.
How would you do it? Thanks! Dave.
D.E.R. Management - IT Project Management Consulting