How to Configure Google Compute Engine Audit SSH Sessions
You set up google compute engine audit ssh sessions by pairing cloud logs with OpenSSH logs. This setup tracks who logs into a virtual machine and when the login starts. Most teams start by turning on cloud login logs and managing SSH keys across instances. When roles or host permissions stay too broad, any team member can run root commands. Host logs might show a login event, but they miss the exact commands run inside. How google compute engine audit ssh sessions work in practice To track l
SSH Session Recording + Session Binding to Device: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up google compute engine audit ssh sessions by pairing cloud logs with OpenSSH logs. This setup tracks who logs into a virtual machine and when the login starts. Most teams start by turning on cloud login logs and managing SSH keys across instances. When roles or host permissions stay too broad, any team member can run root commands. Host logs might show a login event, but they miss the exact commands run inside.
How google compute engine audit ssh sessions work in practice
To track logins on virtual machines, teams combine cloud IAM rules with OpenSSH server logs. On the host side, OpenSSH supports certificate checks for both users and hosts. An admin uses the key tool to sign a user key with a CA key. That signed certificate holds a public key, an identity string, and user or host names. It also holds a set of options signed by the CA key.
OpenSSH certificates use a much simpler format than standard web certificates. When a user logs into a virtual machine, the SSH server checks the signed certificate. It writes the key identity string and the matching principal name into the host log. Meanwhile, the cloud platform records the API call that set up the login or metadata.
Teams often route these host logs from each virtual machine to a central log sink. If a team uses a bastion or jump host, logins pass through that choke point. The jump host logs the initial entry before the user hops to the target machine. Central logs then show the start time, the source IP, and the user identity string.
What native SSH logging solves and what it misses
Native cloud and OpenSSH logs solve the problem of tracking entry at the host door. Security teams can see which user logged into a machine and which CA signed it. They can also verify if a login failed because a key expired or lacked permission. This helps teams spot bad login attempts and review who entered a production server.
Still, entry logs leave a big gap once the shell prompt opens. The native setup decides who logs in, not what individual commands do in flight. Standard SSH server logs do not capture every command run inside an interactive shell. If a user switches to root or edits a local log file, host logs break.
SSH Session Recording + Session Binding to Device: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Also, managing CA keys and shipping logs from hundreds of machines takes constant work. If one virtual machine has a broken log agent, you lose visibility on that host. Teams also struggle when a user opens a tunnel or reads sensitive data on screen. Native host logs cannot rewrite sensitive fields like emails, phone numbers, or card numbers. They also cannot pause a risky command for peer approval before it runs on the host.
Closing the gap between login logs and shell commands
To get full visibility, teams need to move control above the individual virtual machine. Instead of trusting local host agents to ship logs after a command runs, check commands first. This means separating identity checks from the raw SSH keys stored on the machine.
When you check every session at the command level, you gain clear audit trails. You can see the exact input and output for every task without extra host scripts. You can also apply rules that mask national IDs or card numbers in terminal output. This keeps sensitive data safe while giving engineers the shell tools they need to fix issues.
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
Do cloud audit logs show every command run inside an SSH session?
No, cloud logs only record control plane calls and login events. They do not record the shell commands or output that happen inside the session.
How do OpenSSH certificates help with SSH session logs?
An OpenSSH certificate binds a key identity and user name to a public key. When a user logs in, the SSH server writes that clear identity into the host log.
Why is host-level command logging hard to trust during an audit?
Users with root access on a virtual machine can turn off or alter local logs. If logs stay on the host before shipping out, a user can hide their tracks.
Related guides
In this post