SSH Best Pratices
Following ssh best pratices means replacing static keys with signed certificates and strict role limits. You must also check every command that users run during a live session. Many teams start by copying public keys to servers and setting up a central jump host. That basic setup fails when engineers keep broad root roles that never expire. Old keys stay on disks for years, and shared roles hide who ran a bad command. Core ssh best pratices for keys and certificates Static keys create a huge
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.
Following ssh best pratices means replacing static keys with signed certificates and strict role limits. You must also check every command that users run during a live session. Many teams start by copying public keys to servers and setting up a central jump host. That basic setup fails when engineers keep broad root roles that never expire. Old keys stay on disks for years, and shared roles hide who ran a bad command.
Core ssh best pratices for keys and certificates
Static keys create a huge mess as your server fleet grows. When an engineer leaves the team, you must find and delete their public key everywhere. OpenSSH certificates fix this key problem with a much simpler format than web TLS certificates. An authority key signs a user key to create a certificate. That certificate holds the public key, an identity string, principal names, and login options. Instead of copying user keys to every host, you trust the authority key on your servers. You can also sign host keys so users never have to guess if a server is real.
When you sign a user key, you must set a short time window. By default, signed OpenSSH certificates last forever if you do not set an end time. A short life span forces users to get a fresh certificate each work day. You should also list specific principal names inside the certificate. Those names match the exact local system accounts the user can log into. If a developer only needs a read role, the certificate will not allow root login.
Why network bastions and login checks fall short
Most teams pair certificates with a bastion host to keep private servers off the public internet. A bastion gives you a single network choke point to watch incoming traffic. Native SSH certificates and bastions solve the login check problem well. They decide who can open a shell on a specific Linux host. Still, login checks stop working the moment the shell prompt appears.
Once a user logs into a host, native SSH does not check individual commands in flight. A user with a valid shell can still run dangerous scripts or read local files. They might pull customer emails, phone numbers, card numbers, or national IDs from app logs. You can restrict a key to one fixed script, but engineers need interactive shells to fix bugs. Standard system logs also struggle to link shared local accounts back to one person. Teams need a way to inspect commands and rewrite matched data fields during the session.
SSH Access Management: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Separating login roles from live command control
Good security splits server login from command execution. You should keep certificates short and lock down network paths to your hosts. At the same time, you must control what happens inside the shell after login. High-risk commands should wait for a peer to approve them before they run. Sensitive data fields like emails or card numbers should get masked in command output. This approach lets engineers fix broken apps while stopping bad commands and data leaks.
Add command and file guardrails to SSH access
Host firewalls and certificate principals control who opens an SSH session. Yet an allowed user or agent can still run a bad one-shot command or pull sensitive files over sftp. In practice, hoop.dev sits inline on the host as an open-source SSH server with guardrails that uses OpenSSH certificates. For every one-shot command or sftp task an agent or human runs in production, hoop.dev decides to pass, mask, block, or escalate it for review.
Using hoop.dev SSH controls, guardrails check one-shot commands, env variable names, and sftp or scp paths before they run. Port forwards default to deny unless the target is listed. Because interactive shells have no statement boundary and carry no guardrails, teams can turn them off so every command is checked and logged. Check out the MIT-licensed project on GitHub.
Frequently asked questions
Why are OpenSSH certificates better than static SSH keys?
Static keys stay on servers until someone deletes them by hand. OpenSSH certificates hold an identity, principal names, and an end time signed by a central key. Servers trust the central authority key, so you do not have to push keys to every host.
Do OpenSSH certificates expire on their own by default?
No, OpenSSH certificates stay valid forever unless you define a time window during signing. You must set a start and end time when you sign the user key. Setting a window of a few hours removes the risk of lost or stolen keys.
Does a bastion host control what commands an engineer runs?
No, a standard bastion host only forwards network traffic to private servers. Once the user logs in, the bastion does not block bad commands or mask sensitive output. You need command-level controls to approve risky actions and rewrite matched fields like phone numbers.
Related guides
In this post