← All posts Security

SSH hardening checklist for a public Linux server

The Tryssh team · July 21, 2026

Server security fails in two opposite ways: controls are never applied, or they are applied hurriedly and lock out the operator. SSH hardening checklist for a public Linux server needs a third approach—read the effective state, understand the recovery path, then tighten one boundary at a time.

Threat model

The immediate concern is password guessing, root login, stale keys, and unsafe forwarding. Internet-facing SSH hosts are continuously scanned, but exposure is not limited to port 22. A leaked deploy key, an overbroad sudo rule, a mounted Docker socket, or a trusted bastion can turn a small application compromise into control of the machine.

Audit before hardening

Start with read-only evidence:

sshd -T
last -a | head
sudo find /home /root -name authorized_keys -type f

Record the output and identify ownership. Security controls that nobody can explain are future outage material. Every key should map to a person or automation identity. Every listening service should have a reason. Every passwordless privilege should be narrower than “all commands.”

The safe-change rule

Keep a second verified session open, validate with sshd -t, and change one control at a time.

For SSH and firewall changes, keep the current session open and prove a second login before closing it. Validate configuration syntax before reload. Know where the provider console or physical recovery path lives. Security work without recovery planning is just another availability risk.

What good looks like

  • Public-key or short-lived certificate authentication replaces reusable passwords.
  • Root login is disabled or tightly constrained.
  • Authorized keys and privileged groups have named owners.
  • The host firewall exposes only required services.
  • Logs leave the host or are protected from casual deletion.
  • Secrets are not stored in shell history, repositories, or world-readable environment files.
  • Patches, backups, and restore tests have owners and schedules.
  • Changes are reviewed and reversible.

Controls that create false confidence

A nonstandard SSH port reduces log noise but is not access control. Fail2ban slows repeated guesses but does not rescue a leaked key. A VPN narrows network reachability but does not make every device or identity trustworthy. A backup icon is not a recovery plan until a restore succeeds.

Layer controls so a single mistake is survivable. Network policy, strong identity, least privilege, host patching, application isolation, independent backups, and observable changes solve different parts of the problem.

Make the audit repeatable

The most valuable security check is the one the team can run quarterly and after every incident. Save the read-only commands, expected answers, exceptions, and last review date. Avoid a 200-control checklist that nobody completes; prefer ten high-signal controls with clear evidence.

An agent should not become a bypass

An AI assistant with an unrestricted shell can undo the discipline above in one plausible command. Tryssh uses a default-deny risk gate: read-only, metacharacter-free checks may run automatically, while state-changing commands require explicit approval. SSH secrets remain in the macOS Keychain, and the agent's execution channel is separate from the visible terminal.

Use the copilot to collect evidence and explain it. Keep the authority to change the server with the operator. Download Tryssh to run the audit from a native Mac workspace.

Put this control in context

Security controls work as a system. Follow this audit with authorized-key ownership and rehearse the SSH lockout recovery runbook before the next access change. A recovery path is part of the control, not an afterthought.