How to Configure Google Compute Engine Temporary SSH Access
You set up google compute engine temporary ssh access with time-bound cloud roles or short-lived keys. These methods grant an engineer login rights to a virtual machine for a fixed window. Most teams start by adding static public keys to project or instance metadata. Static keys stay valid until an admin removes them by hand. Broad project roles also let users log in to every virtual machine in the project. If a laptop is lost, those standing keys put every server at risk. How google compute e
SSH Access Management + Customer Support Access to Production: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up google compute engine temporary ssh access with time-bound cloud roles or short-lived keys. These methods grant an engineer login rights to a virtual machine for a fixed window. Most teams start by adding static public keys to project or instance metadata. Static keys stay valid until an admin removes them by hand. Broad project roles also let users log in to every virtual machine in the project. If a laptop is lost, those standing keys put every server at risk.
How google compute engine temporary ssh access works natively
Google Compute Engine offers two native ways to limit SSH login time. First, teams can pair OS Login with time-bound cloud identity roles. An admin grants a login role with a time condition attached. When that timer runs out, the cloud role stops working for new logins. Second, teams can push an ephemeral public key to the virtual machine metadata. The guest agent on the server reads that key and sets an expiration time.
Teams can also use OpenSSH certificates on their Linux virtual machines. An OpenSSH certificate holds a public key, identity data, principal names, and options. A Certification Authority key signs all of these fields together. OpenSSH certificates use a much simpler format than X.509 certificates. Certificate support for users and hosts arrived in OpenSSH 5.4. When an admin signs a user key, they set a validity window. The server checks the signature and expiration time before it lets the user in.
Why teams move away from static SSH keys
Static SSH keys create a large cleanup burden for security teams. When an engineer changes roles, someone must find and delete their old public keys. In a cloud project with hundreds of virtual machines, keys often get left behind. Project-wide metadata makes this problem worse. A key stored at the project level works on every virtual machine by default. Only machines that block project keys escape that wide reach.
Bastion hosts and jump hosts add another layer to manage. Teams place a bastion on a public IP to guard private virtual machines. Yet the bastion itself still needs user key updates and OS patching. Temporary keys and short-lived certificates fix the standing key problem. When the clock runs out, the key or certificate will not open new sessions. Admins do not need to log in to delete expired keys from disk.
SSH Access Management + Customer Support Access to Production: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What native temporary SSH controls still miss
Native temporary SSH setup only checks who can log in at the start. Once the shell opens, the native setup does not check commands in flight. An engineer with sudo rights can still run dangerous commands or stop core apps. They can also read local config files that hold emails, phone numbers, or card numbers. If a user copies those files out, native cloud role logs will not show it.
Standard SSH daemon logs record when a session starts and ends. They do not show every command run inside an interactive shell. Also, an expired key or role often only blocks new logins. An open terminal session can stay active past the role expiration window. Teams that need command checks or data masking must look beyond native login roles.
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
What happens when a temporary SSH key expires on a virtual machine?
The server rejects any new login attempts that use the expired key. Existing open terminal sessions may keeps the session active until the user logs out or disconnects.
Do OpenSSH certificates expire on their own by default?
No, OpenSSH certificates stay valid forever unless you set a validity window during signing. Admins must always define a start and end time when signing user keys.
Can native cloud roles block specific Linux commands inside an SSH session?
No, cloud roles only decide if a user can start an SSH session and get sudo rights. They do not inspect or block individual shell commands once the session begins.
Related guides
In this post