Amazon EC2 SSH Session Logging

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up amazon ec2 ssh session logging by shipping Linux host logs to central storage. You can also route user traffic through a central bastion host to capture activity. Many engineering teams start with standard SSH keys and basic system logs on each virtual machine. When teams share broad admin roles, those logs only show that a generic account logged in. You cannot tell which person ran a destructive command or read sensitive files. How native amazon ec2 ssh session logging works On a

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 set up amazon ec2 ssh session logging by shipping Linux host logs to central storage. You can also route user traffic through a central bastion host to capture activity. Many engineering teams start with standard SSH keys and basic system logs on each virtual machine. When teams share broad admin roles, those logs only show that a generic account logged in. You cannot tell which person ran a destructive command or read sensitive files.

How native amazon ec2 ssh session logging works

On a standard Linux instance, the OpenSSH daemon handles all incoming user connections. When a user logs in, the daemon writes login events to the local disk. These records show the time of login, the source IP address, and the Linux user name. If teams share one default user key, every log entry looks the same.

To fix this identity problem, some teams use OpenSSH certificates instead of static public keys. An OpenSSH certificate holds a public key, identity information, principal names, and a set of options. A central Certification Authority key signs these details so the target server trusts them. This format is much simpler than the X.509 format used for web traffic.

When a user logs in with a signed certificate, the server logs the specific key identity. Admins also install log shipping agents on every virtual machine in the cloud account. These agents read the local login files and send them to a central log store. Some teams also run a bastion or jump host at the network edge. Every engineer must pass through this jump host before reaching a private server.

What native host logging solves and what it misses

Native OpenSSH logging and user certificates solve the basic problem of who opened a connection. You can see which human identity authenticated to a specific server at a given time. Shipping those files off the host stops an attacker from deleting login records after a breach. A central bastion also cuts down the number of servers exposed to the public internet.

Still, standard SSH daemon logs only track the front door of the server. The daemon decides who logs in, not what individual commands do during the session. Once a shell starts, standard connection logs do not show the commands an engineer runs. If a user opens a root shell, local history files are easy to bypass or erase.

SSH Session Logging: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Some teams add host audit rules or terminal wrappers on their servers to capture commands. Maintaining these agents across hundreds of short-lived virtual machines takes constant effort. If one host misses an agent update, you lose visibility on that machine. Also, host logs only tell you about a bad command after it has already run. They cannot pause a dangerous command in flight to ask a teammate for approval. They also cannot rewrite sensitive fields like emails, phone numbers, card numbers, or national IDs in output.

Why command-level control matters for cloud servers

Relying only on network rules and login logs leaves a large gap in daily operations. An engineer with valid login rights can still make a mistake on a production host. They might run a script that deletes active files or dumps user records to the screen. When compliance auditors ask what happened during an incident, login timestamps are not enough.

Teams need a way to tie every single shell action back to a verified identity. They also need a way to inspect commands before the operating system runs them. Centralizing this control removes the need to manage custom log scripts on every new machine. It turns server administration from a blind trust model into a verifiable workflow.

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 provides an open-source SSH server with guardrails on the host that uses OpenSSH certificates.

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

Does the OpenSSH daemon log every command a user runs by default?

No, the standard OpenSSH daemon only logs login events, key checks, and connection closures. It does not capture the interactive shell commands a user types after logging in.

How do OpenSSH certificates improve server login logs?

An OpenSSH certificate includes a unique key identity signed by a central authority. The server writes this identity to the log, even if many people share one Linux account.

Why is local shell history unreliable for security audits?

Users with root privileges can edit, delete, or disable their local shell history files at any time. Auditors require tamper-proof records captured outside the control of the local Linux account.

The query runs. The emails stay hidden.