How to Configure EC2 SFTP Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up an ec2 sftp only user by locking the account to file transfers in OpenSSH. You also trap that user inside one specific folder and block normal shell commands. Most teams start by creating a basic Linux user on their server. If you skip strict rules, that user can still run shell commands and read system files. Broad rights let anyone with the key explore your whole machine. How an ec2 sftp only user works in OpenSSH To lock down the account, you first make a dedicated group and use

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 an ec2 sftp only user by locking the account to file transfers in OpenSSH. You also trap that user inside one specific folder and block normal shell commands. Most teams start by creating a basic Linux user on their server. If you skip strict rules, that user can still run shell commands and read system files. Broad rights let anyone with the key explore your whole machine.

How an ec2 sftp only user works in OpenSSH

To lock down the account, you first make a dedicated group and user on the server. You set the user login shell to a non-interactive state so terminal logins fail right away. Next, you update the OpenSSH daemon rules to match this specific user or group. You tell the server to run its internal file transfer program whenever this account logs in. At the same time, you turn off network port forwarding and screen sharing for that user.

You also set up a root jail directory for the account. OpenSSH requires the root account to own this top folder and all parent folders above it. No other user or group can have write rights on that top folder. Inside that locked folder, you create a subfolder where the user can drop and read files. When the user logs in, that locked folder looks like the top of the whole file system.

Managing keys and certificates for file transfers

Once the folder rules are ready, the user needs a safe way to log in. Many teams paste static public keys into a file inside the user home folder. If the jail folder blocks access to the home folder, you move keys to a central path. Managing static keys across many servers takes a lot of manual work when people leave.

OpenSSH offers certificate sign-ins, a feature added in OpenSSH 5.4, to fix static key sprawl. An admin uses a certificate authority key to sign a user public key. This signed certificate holds the public key, an identity string, principal names, and login options. OpenSSH certificates use a much simpler format than standard TLS certificates. You can also bake command limits and time limits right into the signed certificate.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native SFTP restrictions solve and what they miss

Native OpenSSH rules do a great job of blocking interactive shell sessions on your server. A jailed user cannot open a bash prompt or browse system folders outside their assigned path. This setup stops a file transfer user from jumping into other parts of the operating system.

Still, local server settings only control who logs in and which top folder they see. They do not give your team a central place to approve transfers or review live actions. You still have to update Linux accounts and folder permissions on every single instance by hand. If a user downloads sensitive files with emails, phone numbers, or card numbers, OpenSSH does not inspect content. The server daemon only moves raw bytes from disk to the client.

Inspect one-shot SSH commands and file tasks

SSH certificates and host rules decide who is allowed on a machine. Setup alone does not check single commands or block sftp reads on sensitive paths. By design, hoop.dev runs an inline open-source SSH listener on the host where engineers and AI agents keep their normal ssh, sftp, and scp tools. On every production command or file operation, hoop.dev decides whether to pass, mask, block, or hold it for approval.

First, hoop.dev guardrails check one-shot commands and file paths before they run, and hoop.dev data masking masks matched values in file downloads. The audit trail logs the certificate principal, requested action, and verdict without storing session content. Interactive shells carry no guardrails and can be turned off when every action must be checked. Explore the code on GitHub.

Frequently asked questions

Why does my SFTP login fail right after I turn on the folder jail?

OpenSSH checks folder ownership before it lets a jailed user log in. The root user must own the top jail folder, and nobody else can have write rights.

Can an SFTP user still use SSH keys to log in?

Yes, the user can log in with standard SSH public keys or signed OpenSSH certificates. The server checks the key first and then switches the session to file transfer mode.

How do I let the user upload files if root owns the jail folder?

You create a child folder inside the root-owned jail folder after setting up the main path. Then you give the SFTP user ownership and write rights on that inner child folder.

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.