How to Configure Ubuntu SFTP Only User
You create an ubuntu sftp only user by setting up an OpenSSH rule. This rule locks the account to a single folder and blocks shell access. Many teams first share standard Linux accounts when external partners need to send files. That broad access lets file transfer users browse system folders and run shell commands. A minor mistake or stolen key can then expose the whole server. How an ubuntu sftp only user works in OpenSSH OpenSSH handles both normal terminal logins and safe file transfers o
User Provisioning (SCIM) + End-to-End Encryption: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You create an ubuntu sftp only user by setting up an OpenSSH rule. This rule locks the account to a single folder and blocks shell access. Many teams first share standard Linux accounts when external partners need to send files. That broad access lets file transfer users browse system folders and run shell commands. A minor mistake or stolen key can then expose the whole server.
How an ubuntu sftp only user works in OpenSSH
OpenSSH handles both normal terminal logins and safe file transfers over the same port. When a user logs in, the SSH daemon checks its main rule file. You can tell the daemon to match a specific user or a group.
First, you create a dedicated Linux group for all file transfer accounts. Next, you add the new user to this group and disable their login shell. Then, you set up a match block in the OpenSSH daemon settings. This block tells the server to run the built-in SFTP subsystem upon login. It ignores any other command the user tries to run during that session.
You also add a root directory rule inside that same match block. This rule locks the user inside a specific folder path after they log in. Linux requires the root account to own this top folder with strict write rules. Inside that top folder, you create a subfolder where the user can write files. The user sees the top folder as the root of the whole server. They cannot move up the folder tree or read system files outside their space.
Managing keys and certificates for file transfer accounts
Once the folder lock works, teams must manage how these users log in. Passwords are easy to guess, so most teams use SSH keys instead. Static keys still create work because you must update files on every host. OpenSSH 5.4 added user and host certificates to solve this key management problem.
With OpenSSH certificates, a Certificate Authority key signs a user public key. The signed certificate holds the public key, identity info, principal names, and options. It uses a much simpler format than standard web TLS certificates. Your server only needs to trust the CA key to let signed users in. You can also bake command restrictions and source address limits into the certificate itself.
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. They keep external users inside their assigned folders and protect the base operating system. When paired with OpenSSH certificates, you also avoid scattering static public keys across hosts.
Still, native setup rules only decide who logs in and which folder they see. They do not inspect what files move in flight or who approves the session. A valid user can still download sensitive files if someone puts them there. If an old certificate remains valid, the user keeps access until it expires. Managing local groups and root-owned folder trees across dozens of hosts also takes time. One wrong folder permission breaks the login or opens a path to the host.
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
Why does OpenSSH disconnect my SFTP user right after login?
OpenSSH requires the root account to own every folder in the locked path. No other user or group can have write permissions on that top folder. If the user owns their top folder, the SSH daemon drops the session right away.
Can an SFTP only user still use SCP to copy files?
No, forcing the internal SFTP subsystem blocks the legacy SCP protocol on the server. Modern SCP clients use SFTP under the hood, so most tools will still work. Older tools that rely on remote shell commands to copy files will fail.
How do I let the user upload files if root owns the folder?
Keep root as the owner of the main locked folder so OpenSSH stays happy. Create a new subfolder inside that main folder and give ownership to the user. The user can then upload and change files inside that inner subfolder.
Related guides
In this post