How to Configure Azure VM SFTP Only User

Published
Length
3 min read

Luis Felipe Dias

All posts

You create an azure vm sftp only user by locking the account to the internal SFTP subsystem. You also jail that user inside a specific folder so they cannot run a shell. Teams often start by handing out standard SSH keys for basic file transfers. This broad setup lets a file user run commands and read system files on the virtual machine. If a key leaks, an attacker gains full shell control over the cloud host. Locking down the account stops shell login while keeping file uploads working. How

Azure RBAC + User Provisioning (SCIM): the complete guide

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

Free white paper. No spam. Unsubscribe anytime.

You create an azure vm sftp only user by locking the account to the internal SFTP subsystem. You also jail that user inside a specific folder so they cannot run a shell.

Teams often start by handing out standard SSH keys for basic file transfers. This broad setup lets a file user run commands and read system files on the virtual machine. If a key leaks, an attacker gains full shell control over the cloud host. Locking down the account stops shell login while keeping file uploads working.

How to set up an azure vm sftp only user

Setting up an azure vm sftp only user relies on native OpenSSH server rules. First, you create a dedicated Linux group and user account on the virtual machine. You assign this user a disabled login shell in the system user table. This step blocks standard interactive terminal logins right away.

Next, you prepare the folder structure for the chroot jail. OpenSSH requires the root account to own the top jail folder. No other user or group can have write rights on that top path. Inside that root folder, you create a subfolder that the SFTP user owns. The user places their uploaded files inside this inner folder.

Finally, you update the OpenSSH daemon settings to match the new user or group. You tell the SSH daemon to force the internal SFTP subsystem for this match block. You also point the chroot directory setting to the root-owned folder. At the same time, you turn off port forwarding and terminal allocation for that user. After you restart the SSH service, the account can only transfer files inside its jailed path.

Key management and OpenSSH certificates for file users

Once the folder jail works, teams must manage how users log in. Static SSH keys and passwords create long-term risks on cloud virtual machines. A user key stays valid until someone removes it from the server file.

Azure RBAC + User Provisioning (SCIM): architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

OpenSSH supports a simpler certificate format than X.509 for user login. An admin uses a certificate authority key to sign a user public key. The signed certificate holds the public key, identity info, principal names, and login options. By default, signed certificates stay valid forever unless the admin sets a time window. Adding an expiration window helps teams avoid permanent static keys on their cloud hosts.

What native SFTP restrictions solve and what they miss

Native OpenSSH rules solve the problem of unwanted shell commands during file transfers. They keep file transfer accounts inside one folder tree and block network tunneling. This setup works well when a few external partners need to drop files onto a single host.

Still, native OS settings leave large gaps as your server fleet grows. Every virtual machine holds its own local user list and folder permissions. When an engineer or vendor leaves, you must update every machine by hand. Native SSH logs also show who logged in, not the details of every file action across hosts. If a jailed folder holds sensitive files with emails, phone numbers, or card numbers, any valid user can download them. The OS only checks if the user can log in and read the file path. It cannot inspect file contents in flight or require live approval for sensitive downloads.

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

This error usually happens when the chroot folder has bad ownership rules. The root account must own the top jail folder, and no other user can have write access to it.

Can an SFTP only user still use SSH port forwarding?

Yes, unless you block it in the SSH server match rule. You must turn off TCP forwarding and X11 forwarding in the match block for that user or group.

Where can the SFTP user upload files inside a chroot jail?

The user cannot write directly to the top level of the chroot folder. You must create a subfolder inside the jail and give the SFTP user ownership of that inner 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.