DEV Community

Cover image for 13.Restrict Cron Access
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

13.Restrict Cron Access

Lab Information

In alignment with security compliance standards, the Nautilus project team has opted to impose restrictions on crontab access. Specifically, only designated users will be permitted to create or update cron jobs.

Configure crontab access on App Server 3 as follows: Allow crontab access to kareem user while denying access to the jerome user.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines

πŸ”Ή Step 1: Log in to Jump Host

ssh thor@jump_host.stratos.xfusioncorp.com

Password:

mjolnir123

πŸ”Ή Step 2: SSH into App Server 3

ssh banner@stapp03.stratos.xfusioncorp.com

Password:

BigGr33n

πŸ”Ή Step 3: Switch to root

sudo -i
Enter fullscreen mode Exit fullscreen mode

πŸ” Configure Cron Access Control

Linux controls cron access using two files:

/etc/cron.allow

/etc/cron.deny

If /etc/cron.allow exists β†’ only users listed inside it can use crontab. Linux interprets each line as:

β€œThis is a system user allowed to use crontab.”

πŸ”Ή Step 4: Create or Edit cron.allow

echo kareem > /etc/cron.allow
Enter fullscreen mode Exit fullscreen mode

This ensures only kareem can use crontab.

πŸ”Ή Step 5: Verify configuration

cat /etc/cron.allow
Enter fullscreen mode Exit fullscreen mode

Expected output:

kareem

βœ… Final Checklist

βœ” Executed on App Server 3 only
βœ” /etc/cron.allow exists
βœ” Contains only kareem
βœ” jerome not listed
βœ” Verified successfully

🧠 Part 2: Simple Step-by-Step Explanation (Beginner Friendly)
πŸ”Ή How does cron permission work?

Linux checks:

/etc/cron.allow

/etc/cron.deny

Rules:

If cron.allow exists β†’ only listed users can use cron.

If it doesn’t exist β†’ system checks cron.deny.

πŸ”Ή Why create cron.allow?

Because we want:

kareem β†’ allowed

jerome β†’ denied

The easiest and most secure way is:

cron.allow β†’ contains only kareem

Now:

kareem can create crontab

jerome cannot

πŸ”Ή Why not just use cron.deny?

Because deny files are less strict.

Allow-listing is more secure than block-listing.

πŸ” Real-World Context

In enterprise systems:

Only trusted automation users get cron access

Regular users are restricted

Allow-list model is considered more secure


Resources & Next Steps
πŸ“¦ Full Code Repository: KodeKloud Learning Labs
πŸ“– More Deep Dives: Whispering Cloud Insights - Read other technical articles
πŸ’¬ Join Discussion: DEV Community - Share your thoughts and questions
πŸ’Ό Let's Connect: LinkedIn - I'd love to connect with you

Credits
β€’ All labs are from: KodeKloud
β€’ I sincerely appreciate your provision of these valuable resources.

Top comments (0)