Candid photograph of a Linux server terminal with a soft olive-green glow against a dark slate background, conveying a calm technical atmosphere.

Step-by-step guides for system administrators — covering command-line basics, web server setup, and preparation material for technical interviews.

Browse Tutorials

Configuring SSH key-based authentication with multiple keys

Managing several Linux hosts from one workstation becomes fragile when every server accepts the same password. SSH key-based authentication replaces reusable passwords with cryptographic key pairs: the private key remains on the administrator's device, while the matching public key is added to the server. Multiple keys give each machine or trust zone a separate identity.

This pattern suits Australian teams distributed across Sydney, Melbourne, and Brisbane, where hybrid work mixes managed laptops, home connections, and jump hosts. A corporate workstation, a personal test device, and an automation account can each hold a different key, reducing exposure if one device is lost.

The same need appears in the Australian cloud market, where AWS, Microsoft Azure, and Google Cloud operate local regions behind bastion hosts. The Privacy Act 1988 and Australian Privacy Principles still govern personal information handled by covered organisations; changing login technology does not remove access control, audit, or Notifiable Data Breaches obligations.

A reliable setup combines per-device keys, restrictive OpenSSH options, careful sshd configuration, and a tested recovery route. It must also allow one key to be revoked without disrupting the others. The workflow below applies to RHEL, CentOS, Fedora, and compatible Linux distributions.

Plan key ownership and recovery

Map ownership before generating credentials. Decide which people, devices, and automation jobs require access, then issue one Ed25519 key per approved identity. Add an auditable comment such as alice@sydney-admin or deploy-ci-melbourne so operators can identify a public key without exposing an email address.

Keep a register of public-key fingerprints, comments, owners, and expiry dates, but never record private-key contents. Before placing internal examples in a tutorial, remove account names and infrastructure details, and check Linuxtpoint's privacy policy for publication practices. Corporate key registers should follow the organisation's security and privacy procedures.

Generate keys and prove initial access

Create the key on the client, then copy only the .pub file to the destination account. Keep console or cloud-provider access available until a second session succeeds.

ssh-keygen -t ed25519 -a 100 -f ~/.ssh/id_ed25519_sydney -C "alice@sydney-admin"
ssh-copy-id -i ~/.ssh/id_ed25519_sydney.pub alice@sydney.example.com

Give the private key a passphrase and compare its public fingerprint with the server's copy. Tighten local permissions, then test the named key explicitly.

chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519_sydney
ssh-keygen -lf ~/.ssh/id_ed25519_sydney.pub
ssh -i ~/.ssh/id_ed25519_sydney alice@sydney.example.com

An unexpected known_hosts warning or fingerprint difference should stop the rollout.

Configure deterministic key selection

The server's authorized_keys file can contain many public keys, one per line, but it cannot infer which identity was intended. Client aliases pair each host with a specific IdentityFile. IdentitiesOnly yes stops unexpected key offers, while AddKeysToAgent makes a passphrase-backed identity available during the session.

Host syd-app-01
    HostName syd-app-01.internal.example.com
    User alice
    IdentityFile ~/.ssh/id_ed25519_sydney
    IdentitiesOnly yes
    AddKeysToAgent yes

On the server, enable public-key authentication while retaining passwords temporarily. After key access and recovery are proven, set PasswordAuthentication no and PermitRootLogin no in /etc/ssh/sshd_config. Also disable keyboard-interactive password challenges where no PAM-based MFA is required.

sudo sshd -t
sudo systemctl reload sshd

As the target user, protect authorized_keys with chmod 600; on RHEL-family systems, use restorecon when SELinux labels are wrong. For exposed password endpoints and repeated login failures, add the Fail2ban SSH guide and host firewall controls as defence in depth.

Compare SSH authentication options

No single authentication method fits every host. Compare these choices against the number of administrators, machine identity requirements, and recovery controls.

Approach Best fit Main strength Main limitation
Dedicated Ed25519 key One person on one device Small, revocable trust boundary Requires careful client selection
Agent with several keys Frequent switching among trusted hosts Keeps passphrases convenient Loaded identities may be offered without restrictions
SSH certificate Larger fleets or short-lived access Central issuance and expiry Requires a certificate authority
Password login Emergency bootstrap only Familiar recovery mechanism Brute-force and credential-reuse risk

For most multi-device administration, use dedicated keys with explicit aliases. Let ssh-agent hold several identities when switching is frequent, but verify the active set with ssh-add -l and remove stale entries rather than offering every key to every server.

Adjacent web administration needs separate treatment. A WordPress administrator can use a TOTP setup guide for that application's login, but TOTP does not authenticate SSH and does not belong in authorized_keys.

Operational safeguards for a reliable rollout

Use a staged rollout with these controls:

Key inventories should align with the access reviews already required for Australian cloud and office systems. During a Sydney-to-Melbourne handover, for example, compare fingerprints and owners, revoke departed staff promptly, and retain auditable evidence that removal occurred.

The first rollout action is to generate one labelled Ed25519 key for a non-production host, install only its public key, and verify a successful login from a second terminal before changing the server-wide password policy.