Security & Configuration

SSH Key Authentication and Secure Administration

Harden SSH administration with named accounts, protected keys, controlled privilege escalation, and a safe configuration rollout.

SSH provides administrative access to Linux servers, so a compromised SSH credential can expose every service and every hosted site. Prefer named administrator accounts, public-key authentication, and narrowly granted privilege escalation. Avoid sharing the root password among operators: individual accounts make access review and incident investigation possible.

Create and protect an administrator key

Generate a modern key on the administrator's trusted workstation:

ssh-keygen -t ed25519 -a 64 -C "admin-workstation"

Protect the private key with a strong passphrase. Copy only the public key to the intended account, then verify that a new session works before changing server authentication policy. Keep a second recovery route, such as provider console access, available during the transition.

Harden the SSH service carefully

Typical controls include disabling direct root login, limiting allowed users, and disabling password authentication after key access has been proven. Example settings in sshd_config may include:

PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthentication no
AllowUsers adminops

These settings are not universal. Some hosting providers and automation systems rely on password-based or root access. Validate the configuration before reloading:

sshd -t
systemctl reload ssh

On some distributions the service is named sshd rather than ssh. Keep the current session open and test a second login before closing it. A syntax error or incorrect AllowUsers entry can lock out administrators.

Lifecycle, monitoring, and recovery

Remove public keys when staff or vendors no longer need access. Rotate keys if a workstation is lost, a private key is exposed, or ownership is uncertain. Review authorized_keys for unexpected entries and check authentication logs for repeated failures and unfamiliar source addresses. Use multi-factor authentication where supported by the environment.

Do not treat a non-default SSH port as a primary security control; it may reduce background noise but does not replace strong authentication, patching, and firewall policy. Document who owns each key, how emergency access is approved, and how credentials are revoked during an incident.

Share this page Help other developers discover this resource.