How to Configure Google Compute Engine SFTP Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a google compute engine sftp only user by locking the SSH service to file transfers and a jailed folder. You also add the user public key to the instance metadata or guest agent. Teams often grant normal SSH login roles when a person only needs to move files. Broad login roles let users open an interactive shell on the virtual machine. Once inside a shell, a user can read system files, run scripts, or move to other servers. How a google compute engine sftp only user works Google C

User Provisioning (SCIM) + End-to-End Encryption: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up a google compute engine sftp only user by locking the SSH service to file transfers and a jailed folder. You also add the user public key to the instance metadata or guest agent.

Teams often grant normal SSH login roles when a person only needs to move files. Broad login roles let users open an interactive shell on the virtual machine. Once inside a shell, a user can read system files, run scripts, or move to other servers.

How a google compute engine sftp only user works

Google Compute Engine runs a standard OpenSSH server on Linux virtual machines. The cloud guest agent reads public keys from project or instance metadata. It writes those keys to local user folders so people can log in. By default, a valid key grants full terminal access and file transfer rights.

To limit this account, admins create a dedicated Linux group on the virtual machine. They then update the OpenSSH daemon rules to match that specific group. The daemon rule forces the internal file transfer subsystem to run on every login. It also turns off port forwarding, tunnel creation, and interactive shell requests.

Next, admins set up a change root directory to jail the account. OpenSSH requires the root user to own the top folder of this jail. No other user or group can have write rights on that top folder. Inside the jail, admins make a writable subfolder where the user drops or reads files. You must also stop the cloud guest agent from adding this user to admin groups.

Managing keys and certificates for file transfers

Static public keys in cloud metadata stay active until someone deletes them by hand. If a contractor leaves, an old key in project metadata might still work. Teams can use OpenSSH user certificates instead of raw public keys to fix this.

User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

A certification authority key signs a user public key to make an OpenSSH certificate. This certificate holds a public key, identity details, principal names, and login options. OpenSSH certificates use a much simpler format than standard TLS certificates. You can embed command limits and expiry times right inside the signed certificate.

What native file transfer locks leave open

Native OpenSSH group rules and folder jails solve the shell login problem well. They stop a file transfer user from running bash commands or viewing system folders. The operating system enforces the folder boundary as soon as the user logs in.

Still, native setup rules only decide who logs in and which folder they see. They do not check what happens inside the session while files move. Standard server logs only show that a user opened a session, not every file action. Also, local daemon rules live on each virtual machine disk. When teams run dozens of machines, keeping local config files and folder permissions in sync takes heavy manual work. Shared static keys also make it hard to tie a file upload to one specific person.

Check SSH commands and file transfers on the host

OpenSSH keys and certificates decide who can log into a Linux host. They do not check what a one-shot command or file transfer does once the session starts. With hoop.dev, you run an open-source SSH server with guardrails inline on the host. On every one-shot command or file transfer an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

When a caller runs a one-shot command or moves a file, hoop.dev guardrails check the command or path before it runs, and hoop.dev data masking masks matched sensitive patterns in downloads and output. Interactive shells carry no guardrails because keystrokes have no statement boundary. Teams can turn interactive shells off and allow only commands and file tasks. The audit trail logs who connected and what was allowed or refused, without storing keystrokes or file bytes. See the source on GitHub.

Frequently asked questions

Why does my SFTP user get disconnected right after logging in?

OpenSSH drops the session if the jailed top folder has bad ownership rules. The root account must own the folder, and no other user can have write rights.

How do I stop Google Compute Engine from granting sudo rights to the user?

Create the Linux user on the machine first and manage their authorized keys locally. Do not assign project-wide OS Login admin roles to a file transfer account.

Can an SFTP only user still forward ports through the virtual machine?

Yes, unless you turn off TCP and agent forwarding in the OpenSSH daemon rules. Always block forwarding options inside the match block for your restricted user group.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.