How to Set Up SSH Key Authentication for Multiple Team Members

How to Set Up SSH Key Authentication for Multiple Team Members

One shared server login with one shared password is the fastest way to lose track of who can reach your server. When someone leaves, you cannot remove their access without changing the password for everyone. Setting up ssh key authentication multiple users the right way gives each person their own account and their own key, so access can be granted and revoked one person at a time. This guide covers the setup, the daily workflow, and the offboarding step teams most often skip.

The model is simple. Each team member generates a key pair on their own machine. The public half goes into their account on the server. The private half stays on their machine and never travels to the server. The server checks the key at login and never asks for a password. If a key is lost or a person leaves, you delete one line from one file and that access is gone.

SSH Key Authentication Multiple Users: Create One Account Each

Start by creating a separate account for each person. Shared accounts hide who did what in the logs, and they make offboarding a negotiation instead of a single command. Create the account, add it to the sudo group only if the person needs admin rights, and set up the SSH directory in one pass.

sudo adduser alice
sudo usermod -aG sudo alice
sudo mkdir -p /home/alice/.ssh
sudo chmod 700 /home/alice/.ssh
sudo chown alice:alice /home/alice/.ssh

Repeat the same steps for each team member, changing only the username. Resist the urge to give everyone sudo by default. Developers who only deploy code need write access to the web root, not full root. Our guide on creating sudo users and disabling root login explains the account setup in more depth, including why root login should stay off once individual accounts exist.

Each person then generates their own key pair. The ed25519 type is the current sensible default: short keys, fast logins, and support on every modern client. The passphrase on the key matters, because it protects the key if the laptop is stolen. A key without a passphrase on an unencrypted laptop is an open door, not a credential.

ssh-keygen -t ed25519 -C "alice@company"
cat ~/.ssh/id_ed25519.pub

Collect Public Keys and Install Them Safely

Ask each person to send you their public key, the .pub file, never the private key. A public key starts with ssh-ed25519 and ends with the comment. If someone sends a file named id_ed25519 without the .pub ending, stop and ask again, because that file is the private half and must never be emailed or pasted into chat.

Append each public key to that person’s authorized_keys file. The file lives at ~/.ssh/authorized_keys inside their home directory. One key per line, no extra blank lines inside a key, and mode 600 on the file. A key split across two lines will fail silently, and the login attempt will fall back to a password prompt that tells you nothing about the real cause.

echo "ssh-ed25519 AAAA... alice@company" | sudo tee -a /home/alice/.ssh/authorized_keys
sudo chmod 600 /home/alice/.ssh/authorized_keys
sudo chown alice:alice /home/alice/.ssh/authorized_keys

Have each person test their login before you call the setup done. They should log in with their key and confirm they reach their own account, not a shared one. If you also plan to turn passwords off entirely, our guide on disabling password login in favor of SSH keys covers the order of operations, and our SSH hardening guide for Ubuntu 24.04 covers the server settings that pair with team key access.

Manage Access Day to Day with Groups and Key Comments

Groups keep team access manageable as the team grows. Instead of editing permissions per person per directory, put people in groups that match their job: a deploy group with write access to the web root, a logs group with read access to application logs, a sudo group for admins. When a new hire joins, you add them to the right groups. When someone changes roles, you move them between groups. The server permissions stay stable while the roster changes.

sudo groupadd deploy
sudo usermod -aG deploy alice
sudo chgrp -R deploy /var/www/example.com
sudo chmod -R g+w /var/www/example.com/wp-content/uploads

Key comments, the trailing text on each public key line, are your inventory. Keep them in the form name@device, such as alice@laptop and alice@desktop, so you can tell at a glance which key belongs to which person and which machine. A key with a vague comment like user@host becomes a mystery six months later, when you need to know whether it is safe to delete.

Managing team ssh public keys is mostly inventory work: know which key belongs to whom, and check authorized_keys file permissions after every edit, since a file with loose modes gets ignored by the server. For larger teams, consider a small amount of automation. A script that reads public keys from a private repository and writes the authorized_keys files removes the manual copy step and its typos. Keep that repository private, since public keys are not secret but the roster of who has access is still information worth keeping out of public view. Review the script output after each run, because an automated overwrite that drops a key locks someone out just as surely as a manual mistake.

Remove Access the Day Someone Leaves

Offboarding is where most team setups fail. The routine to revoke ssh access team member by team member should be written down before anyone leaves, so it runs the same way under time pressure. The steps are short, but they must happen the same day access should end, not at the next cleanup. Delete the person’s public key from their authorized_keys file, lock or remove the account, and check for any other access they held, such as deploy keys, database users, and panel logins.

sudo sed -i '/alice@laptop/d' /home/alice/.ssh/authorized_keys
sudo usermod --lock alice
sudo userdel -r alice

Read the authorized_keys file after the edit to confirm the key is gone, rather than trusting the command output. A sed pattern that does not match the comment leaves the key in place with no error. Also check for keys the person may have added themselves to other accounts, such as a deploy account, since a key copied into a shared account survives the removal of their personal account. Our guide to managing sudo users and permissions on a VPS covers account audits that catch these leftovers.

Two limits round out the picture. Key authentication proves possession of a key, not the identity of the person holding it, so a shared laptop with an unlocked key is a shared login in practice. And keys do not expire by default, so a key you forget about grants access forever. A quarterly review of every authorized_keys file on the server, matched against the current team roster, closes both gaps as far as process can. The technology is simple. The discipline of keeping the roster current is the part that actually protects the server.

Ditulis oleh

Firdaus Safari Putra

Founder, PT FirKaizen Digital Solutions

Firdaus Safari Putra adalah founder PT FirKaizen Digital Solutions. Ia membangun dan mengoperasikan infrastruktur server di balik panduan ini, dan menulis berdasarkan apa yang benar-benar ia jalankan, uji, dan ukur — bukan teori.