Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I protect my CRON scripts from remote users?

I am currently working on a new project which involves using CRON jobs.

The CRON script basically runs an SQL query, generates the data into a file, and send that file to another server via FTP.

The script is on a live website (www.website.com/sendOrders.php)

I don't see any security issues or threats, and I think it is highly unlikely that anyone will find the PHP script on the server. However I don't want the script to be executed by any outsiders.

Is there a way I can protect this script?

Thanks Peter

like image 329
Peter Stuart Avatar asked Dec 01 '22 21:12

Peter Stuart


1 Answers

You could move your "secret files" into a subfolder, then create a .htaccess file in there that prevents access to that file from everyone, except the server that is running the Cronjob.

Example:

DENY FROM ALL
ALLOW FROM 123.123.123.123

If you have shell access you might also put the scripts outside of the accessible folder and run directly via command line or cronjob like this: php script.php.

like image 119
chrki Avatar answered Dec 11 '22 15:12

chrki