Interview Prep/Linux/Users, groups and access control

You need to onboard 50 new developers onto a shared build server, each with their own account and SSH key. How do you do it?

BeginnerScenarioUsers, groups and access control
Answer

Situation read → Bulk, repeatable user creation with consistent groups and key-only login.

What I'd do →

  1. Get a CSV of username,pubkey from the ticket.
  2. Create a developers group once: sudo groupadd developers.
  3. Loop over the file:
while IFS=, read -r u key; do
  sudo useradd -m -s /bin/bash -G developers "$u"
  sudo install -d -m 700 -o "$u" -g "$u" /home/$u/.ssh
  echo "$key" | sudo tee /home/$u/.ssh/authorized_keys >/dev/null
  sudo chown "$u:$u" /home/$u/.ssh/authorized_keys
  sudo chmod 600 /home/$u/.ssh/authorized_keys
done < users.csv
  1. Lock passwords (passwd -l) since login is key-only, and verify with getent group developers.

Why → Scripted creation avoids typos and wrong permissions that break key auth.

Interview tip → Say that beyond a handful of servers you would do this with Ansible's user and authorized_key modules, or central identity (LDAP/SSSD).

All Linux questions Roadmap: Linux

More on Users, groups and access control