How to Configure Rocky Linux SFTP Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a rocky linux sftp only user by forcing the internal SFTP subsystem. You also lock that user account inside a root-owned jail folder in OpenSSH. Teams often build this setup when contractors or apps need to transfer files. If you grant broad SSH permissions, a file user gets an interactive shell. That user can then browse system folders and run local commands on the host. How a rocky linux sftp only user works in OpenSSH OpenSSH manages both interactive shell sessions and file tran

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 rocky linux sftp only user by forcing the internal SFTP subsystem. You also lock that user account inside a root-owned jail folder in OpenSSH. Teams often build this setup when contractors or apps need to transfer files. If you grant broad SSH permissions, a file user gets an interactive shell. That user can then browse system folders and run local commands on the host.

How a rocky linux sftp only user works in OpenSSH

OpenSSH manages both interactive shell sessions and file transfers over the same port. When a normal user logs in, the SSH daemon starts their login shell. To stop shell access, you create a dedicated group for file transfer accounts. You then add a match rule in the SSH daemon settings for that group.

This rule forces the session to run the built-in SFTP subsystem upon login. It ignores any shell command the client tries to send during the connection. You also set a jail folder path in that same match block. The operating system changes the apparent root directory for that user right after login.

Strict folder ownership rules apply to every jail folder in OpenSSH. The root user must own the top jail folder and every parent directory above it. No other user or group can have write permissions on that top folder. If permissions are too open, the SSH daemon refuses the connection right away.

To let the user upload files, you create a subfolder inside the jail. You give the SFTP user ownership and write permissions on that inner subfolder. You should also disable port forwarding and X11 forwarding in the match rule. This stops the user from tunneling network traffic through the file server.

Using OpenSSH certificates for file transfer accounts

Static SSH keys and passwords create rotation headaches on shared file servers. OpenSSH 5.4 added support for user and host certificate login. These certificates use a simpler format than X.509 certificates used in TLS. You use the key generation tool to sign a user public key with a CA key.

The signed certificate holds the public key, an identity string, and valid principal names. It also holds a set of options that control what the session can do. By default, a signed certificate stays valid forever unless you set a time window. Teams set short validity windows so access expires on its own without manual cleanup.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can also bake restrictions directly into the signed certificate options. This gives you a second check alongside the SSH daemon group match rules. The server checks the CA signature and matches the principal name before starting SFTP.

What native SFTP restrictions solve and what they leave open

Native OpenSSH jailing and forced SFTP commands solve the shell escape problem. They keep a file transfer account inside one directory tree on your server. They also block network tunneling and terminal allocation for that specific Linux user.

Still, local OS user rules only decide who can log in to the host. They leave a large operational gap once the SFTP session starts running. You still have to create and maintain local Linux users across every server. Standard system logs only show basic login events unless you raise log verbosity.

Native SFTP rules also cannot inspect the data inside the files being moved. If an engineer downloads a file full of customer emails or card numbers, SFTP sends it. The server cannot mask sensitive fields like phone numbers or national IDs in flight. It also cannot ask a team lead for approval before a sensitive download begins.

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 connection close right after login?

This usually happens when the jail folder has wrong ownership or write permissions. Ensure the root user owns the top jail directory and nobody else can write to it.

Can a rocky linux sftp only user still upload files inside a root-owned jail?

Yes, the user can upload files if you create a writable subfolder inside the jail. Root owns the top jail folder, while the SFTP user owns the inner drop folder.

Do I need an external shell binary inside the SFTP jail directory?

No, you do not need any binaries or libraries inside the jail folder. The built-in OpenSSH SFTP server runs in memory after the jail step finishes.

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.