How to Configure EC2 Session Logging

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up ec2 session logging by routing host shell activity to cloud storage. This setup captures terminal input and output from every active user connection. Most engineering teams start by enabling the native cloud agent on their virtual machines. They link the instance role to a central log group or storage bucket. When host roles are too broad, users can still run harmful commands or read sensitive files. How native ec2 session logging works To capture terminal activity on cloud hosts,

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 ec2 session logging by routing host shell activity to cloud storage. This setup captures terminal input and output from every active user connection. Most engineering teams start by enabling the native cloud agent on their virtual machines. They link the instance role to a central log group or storage bucket. When host roles are too broad, users can still run harmful commands or read sensitive files.

How native ec2 session logging works

To capture terminal activity on cloud hosts, you need an agent on each server. This background agent runs inside the virtual machine and manages incoming user shells. You must also attach an identity role to the server itself. That role gives the agent permission to send text streams to cloud storage.

Next, an admin defines logging rules inside the cloud management console. You pick a storage bucket or a log group as the destination. You also set up encryption keys so only approved auditors can read the saved logs. When an engineer starts a shell, the agent captures the terminal stream.

The agent buffers the text and sends it to your storage destination. Some teams choose to stream these logs in real time for live review. Other teams wait for the session to close before uploading the full log file. Both methods rely on the host agent staying active and healthy during the shell.

What native host logging solves and what it misses

Native host logging gives security teams a paper trail after an incident happens. It removes the need to manage public network ports or shared SSH keys. Auditors can review past terminal logs to see which user logged into a server. This helps teams meet basic audit rules for cloud server access.

Still, native logging only records events after they run on the host. It decides who can open a shell, not what individual commands do in flight. Once a user connects, they get full access to the local shell. If the user has root rights, they can stop the agent or alter local files.

Raw terminal logs also capture every character printed to the screen. If an engineer inspects a file with customer data, that data enters the log. Sensitive fields like emails, phone numbers, card numbers, and national IDs end up in plain text. Now your log storage holds raw secrets that require strict access rules.

SSH Session Logging + Session Binding to Device: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Managing permissions and sensitive data in terminal logs

Keeping host roles tight across hundreds of servers takes constant work. Teams often share broad roles to fix production bugs faster during an outage. One shared role means ten engineers might log in with the same host user. When you read the logs later, you must match cloud events to host commands.

Terminal streams also break down when users run scripts or subshells. A user might run a script that pulls database records to the screen. The log shows the script name and the raw output on the terminal. It does not stop a dangerous command before it deletes a production folder.

To reduce risk, teams need controls that check commands before they run. They also need data masking that rewrites matched fields in results in real time. Instead of just saving text after the fact, teams can approve risky actions first. This keeps bad commands from running and keeps private data out of log files.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev sits inline in the wire protocol beside those services as an open-source proxy, a sidecar for your Postgres or API. On every query an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Does native cloud logging capture SSH key logins by default?

No, standard SSH connections bypass the cloud management agent unless you route SSH through it. Direct network logins only write basic entries to local system files on the disk.

Can root users bypass host-based terminal logging?

Yes, a user with root permissions on the server can stop the local agent process. Once the agent stops, the server cannot send terminal data to your log storage.

What happens to sensitive data printed during a logged shell session?

The logging agent captures all screen output and writes it directly to your storage bucket. Any emails, card numbers, or secrets shown on screen are saved in the log file.

The query runs. The emails stay hidden.