Skip to main content

Claude Prompt for a User Management Automation Script

Automate Linux user lifecycle — onboarding, offboarding, group assignments, sudo policies, and access auditing from a CSV roster.

Vul de plaatshouders in

Edit the values, then copy your finished prompt.

Jouw Prompt
prompt.txt

                                

What this prompt does

This prompt builds a user management automation suite for [server_count] [distro] servers handling [user_count] users across [group_structure] groups. It reads a CSV roster (name, email, department, role, ssh_public_key, start_date, end_date) to create or update accounts with [default_shell] and group memberships, places authorized_keys with correct permissions, configures per-role sudoers via [role_permissions] using validated drop-in files, offboards by disabling rather than deleting accounts, generates a quarterly access audit flagging accounts inactive over [inactive_days] days, and syncs state across servers via [sync_method] with a dry-run.

The variables define your access model. [group_structure] and [role_permissions] map roles to groups and sudo rights, [inactive_days] sets the audit's staleness flag, and [sync_method] propagates changes across the fleet. The disable-not-delete offboarding and visudo syntax checking are deliberate safeguards: the former preserves home directories as archives, the latter prevents a broken sudoers file.

When to use it

  • Onboarding and offboarding access is rotting because it is done manually
  • Driving user lifecycle from a CSV roster instead of ad-hoc commands
  • You insist on disable-not-delete for offboarding to preserve home directories
  • Configuring per-role sudoers safely with visudo syntax checking
  • Producing a quarterly audit that flags accounts inactive over a threshold
  • Synchronizing user state across many servers with a dry-run preview

Example output

You get scripts that parse the CSV roster and create or update accounts, write authorized_keys with 700/600 permissions, generate /etc/sudoers.d drop-in files validated with visudo per [role_permissions], an offboarding routine that locks, expires, kills sessions, and archives the home directory, a quarterly audit report of users, groups, sudo privileges, last login, and inactive accounts, and a [sync_method]-based sync with dry-run.

Pro tips

  • Always run the dry-run before applying; seeing planned account and permission changes across [server_count] servers prevents a surprise mass change
  • Keep offboarding as disable-not-delete so a departed user's home directory survives as an archive for audit or handover
  • Validate every sudoers change with visudo via the drop-in approach; a syntax error in sudoers can break sudo for everyone
  • Make [role_permissions] least-privilege — readonly-ops viewing logs should not inherit broader rights by accident
  • Treat the [inactive_days] audit flag as actionable; stale accounts are exactly the ones that quietly become a risk
  • Ensure authorized_keys permissions land at 700 for .ssh and 600 for the file, or SSH will silently refuse the key
  • Drive everything from the CSV roster as the single source of truth, including start_date and end_date, so onboarding and offboarding are a data change rather than a manual ssh-into-each-box chore
  • Keep [group_structure] and [role_permissions] aligned; if a role's group membership and its sudoers entry drift apart across [server_count] servers, you get users who can do more or less than the roster intends

Frequently Asked Questions

Does offboarding delete the user account?
No. Offboarding disables rather than deletes: it locks the password, expires the account, kills active sessions, and revokes SSH keys while preserving the home directory as an archive. This keeps an audit trail and lets you recover files, which a hard delete would destroy.
How does it avoid breaking sudo across the servers?
It configures sudoers rules through /etc/sudoers.d drop-in files and runs visudo syntax checking before applying them. Because a syntax error in the main sudoers file can lock everyone out of sudo, the validation step and drop-in isolation are what keep a bad rule from taking down access.
Can I preview changes before they hit every server?
Yes. The sync uses `[sync_method]` with a dry-run mode that shows the planned changes before applying them. Reviewing the dry-run across `[server_count]` servers lets you catch an unintended mass account or permission change before it is made everywhere.
What does the access audit report show?
The quarterly audit lists every user, their group memberships, sudo privileges, last login date, and any accounts inactive for more than `[inactive_days]` days. Flagging stale accounts keeps the access list honest over time, since dormant accounts are a common and avoidable security risk.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

Meer in Linux & Shell Scripting Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support