SSH Hardening

Published
Length
3 min read

Luis Felipe Dias

All posts

You accomplish ssh hardening by turning off password logins, locking down network paths, and using signed certificates. These steps stop attackers from guessing passwords or stealing static keys that never expire. Most teams start by routing traffic through a bastion or jump host and copying public keys to servers. Over time, those static keys pile up and give engineers broad shell privileges across too many machines. How native ssh hardening works with OpenSSH certificates A core step in ssh

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You accomplish ssh hardening by turning off password logins, locking down network paths, and using signed certificates. These steps stop attackers from guessing passwords or stealing static keys that never expire. Most teams start by routing traffic through a bastion or jump host and copying public keys to servers. Over time, those static keys pile up and give engineers broad shell privileges across too many machines.

How native ssh hardening works with OpenSSH certificates

A core step in ssh hardening is moving away from static public keys on every host. OpenSSH added certificate support for users and hosts in version 5.4. Instead of copying keys to every server, you create a central authority key. You then use the OpenSSH key tool to sign a user key or a host key. The resulting certificate is much simpler than the X.509 format used in web traffic.

Each OpenSSH certificate holds a public key, an identity string, and a list of principal names. Principals are the user names or host names that the certificate allows. The certificate also holds a set of options and a time window for when it works. By default, a signed certificate lasts forever unless you set a start and end time during signing.

When a user logs in, the server checks the signature against the trusted authority key. If the signature matches and the principal name is allowed, the server opens the shell. Host certificates work the same way in reverse. They let a client verify the server identity without prompts about unknown hosts.

Why network and login rules are only half the job

Teams also harden servers by turning off root logins and blocking password prompts in the server settings. Many teams put a jump host at the edge of the network to limit open ports. These steps do a great job of controlling who can reach a server and log in.

Still, login checks only decide who gets through the door at the start of a session. Once a user lands in a Linux shell, OpenSSH steps out of the way. A user mapped to a shared admin principal can run any command that the local Linux account allows. They can read private files, dump local data, or stop running apps without a second check.

SSH Access Management: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Certificate options can restrict port forwarding or lock a key to a single forced command. Yet writing forced commands for every daily task breaks normal fix workflows for engineers. Standard server logs also record who logged in, not what commands ran or what data returned on screen. When auditors ask what happened during an incident, login logs leave a wide visibility gap.

Practical steps to tighten your server settings

Start by setting short time windows every time you sign a user certificate. A key that expires after a few hours cannot be reused next week if a laptop is lost. Next, map each certificate principal to the least privileged local user account on the target machine. Avoid mapping broad engineering groups to root or shared admin accounts unless they need full control.

Finally, pair your host and key rules with controls that inspect commands during the session. Checking individual commands and masking sensitive output like emails or card numbers keeps data safe in flight.

Inspect one-shot SSH commands and file tasks

SSH certificates and host rules decide who is allowed on a machine. Setup alone does not check single commands or block sftp reads on sensitive paths. By design, hoop.dev runs an open-source SSH listener on the host where people and agents keep their normal ssh, sftp, and scp tools.

First, hoop.dev guardrails check one-shot commands and file paths before they run. Next, hoop.dev data masking masks matched values in file downloads. The audit trail logs the certificate principal, requested action, and verdict without storing session content. Interactive shells carry no guardrails and can be turned off when every action must be checked. Explore the code on GitHub.

Frequently asked questions

What is the first step in ssh hardening?

Turn off password logins and direct root logins in the server settings. Then move from static public keys to short-lived OpenSSH user certificates signed by a central authority key.

How do OpenSSH certificates differ from X.509 certificates?

OpenSSH uses its own certificate format, which arrived in version 5.4. It is much simpler than X.509 and stores a public key, identity info, principals, and options.

Do OpenSSH user certificates expire automatically by default?

No, an OpenSSH certificate remains valid forever unless you specify a time window when you sign it. Always set a clear start and end time when signing user keys.

The query runs. The emails stay hidden.