How to Configure EC2 Temporary SSH Access
You can set up ec2 temporary ssh access by signing user public keys with an OpenSSH Certification Authority key. You then set a short validity window on the signed certificate so it expires on its own. Many teams start by copying static public keys onto each server. Static keys stay valid until someone deletes them from the host. If a team grants broad Linux permissions, one leaked key puts every server at risk. How ec2 temporary ssh access works with OpenSSH certificates OpenSSH added certif
SSH Access Management + Customer Support Access to Production: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You can set up ec2 temporary ssh access by signing user public keys with an OpenSSH Certification Authority key. You then set a short validity window on the signed certificate so it expires on its own. Many teams start by copying static public keys onto each server. Static keys stay valid until someone deletes them from the host. If a team grants broad Linux permissions, one leaked key puts every server at risk.
How ec2 temporary ssh access works with OpenSSH certificates
OpenSSH added certificate login for users and hosts in version 5.4. An OpenSSH certificate uses a much simpler format than X.509 certificates. It holds a public key, identity data, principal names, and options. A Certification Authority key signs all of these fields together.
To set this up, your team creates a central authority key pair. You place the public authority key on your Linux servers. You then tell the SSH daemon to trust that authority key. Now you do not need to copy user keys to servers.
When an engineer needs to log in, they send their public key for signing. The signing tool creates a user certificate with a key identity. It also adds one or more principal names to match Linux user accounts. You must set a validity time window during the signing step. By default, signed OpenSSH certificates stay valid forever if you skip the time window. Setting an end time makes sure the certificate stops working after a few hours. The engineer presents the signed certificate to the server to log in. The server checks the authority signature, the principal name, and the expiration time.
What native temporary SSH setup solves and what it misses
Short-lived OpenSSH certificates solve the problem of leftover static keys on servers. You no longer need to clean up old keys when someone leaves the team. Once the validity window ends, the user cannot start a new SSH session. You can also route traffic through a bastion or jump host to limit network exposure.
Still, certificate login only checks who can open a shell session. Once the session starts, the SSH daemon steps out of the way. The Linux account permissions decide everything the user can do next. If the user maps to a shared admin principal, they can run any command. They can read private files, change system settings, or dump local data.
SSH Access Management + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Standard SSH logs record who logged in and which key identity they used. Those logs do not show every command run inside an interactive shell. They also cannot block a dangerous command while the session is active. If a command prints customer emails, phone numbers, card numbers, or national IDs, raw text appears on screen. Certificate options can force a single fixed command, which helps for simple tasks. Yet engineers fixing live issues often need more flexibility than one fixed command allows.
Managing principal mapping and host trust at scale
Running your own authority key takes careful planning across your cloud fleet. You must guard the private authority key inside a secure signing service. Anyone who gets that private key can sign certificates for any principal name. Teams usually link the signing step to their identity provider so users log in first.
You also need clear rules for how principal names map to server accounts. If every engineer gets the same root principal, your audit logs lose detail. The server log shows the certificate identity, not the actions tied to one person. Splitting principals by role helps limit who can log into sensitive hosts. Still, host-level roles cannot inspect or filter live shell traffic on their own.
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
How do OpenSSH certificates differ from X.509 certificates?
OpenSSH certificates use a custom format that is much simpler than X.509. They store a public key, an identity string, principal names, and options signed by an authority key.
What happens if you do not set an expiration time on an OpenSSH certificate?
If you skip the validity window when signing, the certificate stays valid forever by default. Always define a clear start and end time to keep logins short-lived.
Can OpenSSH certificates stop an engineer from running bad commands?
A certificate can force a single preset command using certificate options. If you allow an interactive shell, the certificate cannot inspect or block individual commands during the session.
Related guides
In this post