SecureTools Logo
DashboardList Your Software
All Articles
SecureToolssecuretools.live • November 2026
How-to Guide•File Sharing

How to Harden an SFTP Server: A Step-by-Step Security Checklist

Mohamed SirajMohamed Siraj(Founder, SecureTools.live)
•
Published November 14, 2026
•
11 min read
Teal fiber patch panel with cables in a data center rack representing a hardened file transfer host
TL;DR

To harden an SFTP server, run it as a dedicated service, allow key-based login only, confine each partner to their own directory, restrict what each key may do, switch off forwarding and terminals, and log enough to notice trouble. Then test every control by trying to break it. This guide uses the documented behavior of OpenSSH, the server most teams run.

Explore SFTP and Secure FTP Software

Compare SFTP servers and secure FTP software on SecureTools.

Browse Tools
TABLE OF CONTENTS
15 sections
01.Before you start: define what the server is for02.Step 1: Run SFTP as its own service, not a shared shell server03.Step 2: Turn off passwords and root login04.Step 3: Lock each partner into a chroot directory05.Step 4: Use the internal SFTP subsystem and force it06.Step 5: Limit who can log in at all07.Step 6: Restrict each key08.Step 7: Switch off forwarding and terminals09.Step 8: Reduce guesswork for attackers10.Step 9: Turn on useful logging and watch it11.Step 10: Patch, back up and manage keys over time12.Verify the hardening by testing it13.A one-page hardening checklist14.Frequently Asked Questions15.Sources and Further Reading

Before you start: define what the server is for

Hardening works best when you know exactly what you are protecting. An SFTP server that exists to receive nightly files from five partners needs very different rules from one that gives staff shell access to a maintenance machine. Decide first which accounts will use the service, what they should be able to reach, and what they should never be able to do.

This guide assumes OpenSSH, the SSH server shipped with most Linux and BSD systems, because its behavior is clearly documented in the sshd_config manual. If you use a different product, the same ideas apply, but the setting names will differ. For the protocol background, see our comparison of SFTP, FTPS and HTTPS.

Work on a test machine or a maintenance window first. A mistaken SSH setting can lock out administrators, so keep a second session open while you make changes and confirm you can still log in before closing it.

Step 1: Run SFTP as its own service, not a shared shell server

The safest SFTP server is one that does nothing else. If partners connect to the same machine that staff use for administration, any weakness in one role becomes a weakness in both.

Bundled network cables in a server rack illustrating a dedicated file transfer service
  • Use a dedicated host or virtual machine for partner file transfer.
  • Keep partner accounts separate from administrator accounts, and never reuse names or keys between them.
  • Remove software the machine does not need, because every extra service is more to patch.
  • Place the server where network rules can limit which systems it talks to, such as allowing partners in and your internal file store out, and little else.

This is the same principle behind our guide to zero trust for file sharing: grant access to specific things for specific reasons, not to a general-purpose machine.

Step 2: Turn off passwords and root login

Passwords can be guessed, reused or phished. Keys are far harder to attack in bulk. The sshd_config manual lists PasswordAuthentication as enabled by default, so switching it off is a deliberate step. Keep PubkeyAuthentication enabled, since that is how partners will log in.

Also look at PermitRootLogin. The manual describes its default as prohibit-password, which blocks password logins for the root account but still allows keys. Setting it to no removes the root account from remote login entirely, which is the better choice for a partner-facing server. Administrators can sign in with named accounts and use elevated rights afterwards, leaving a clearer audit trail.

If a partner insists on passwords, treat it as an exception: document it, limit the account, and consider a second factor. Our guide to two-factor authentication and SSO for file sharing accounts explains the options. Before disabling passwords, make sure you have installed your own administrator key and tested it.

Step 3: Lock each partner into a chroot directory

By default, an SSH user can wander through any part of the filesystem their account can read. A chroot confines the session to a chosen folder so that the folder looks like the entire system. In OpenSSH the ChrootDirectory setting does this after authentication.

There is one rule that trips up many first attempts. The manual states that at session start sshd checks that every component of the chroot path is a directory owned by root and not writable by group or others. If any part is writable, the session fails. The practical consequence is that a partner cannot write directly into the top of their chroot. The usual pattern is to make the chroot root owned by root and create a subfolder inside it, such as an upload folder, owned by the partner account.

  • Give each partner a separate chroot so they cannot see one another's files.
  • Create explicit inbound and outbound subfolders owned by the relevant account.
  • Use a home directory pattern if you want the path to follow the user name automatically.
  • Check ownership of every folder in the path, not just the last one.

A chroot is not a cure-all, and it does not replace permissions, but it removes the easiest route to exploring the server.

Step 4: Use the internal SFTP subsystem and force it

OpenSSH needs to be told which program handles the SFTP subsystem. The manual notes that no subsystems are defined by default, and recommends internal-sftp, an in-process server, as the easy choice for chroot setups because it does not require a copy of system files inside the chroot.

Hands typing at a laptop keyboard while editing server configuration settings

Pair that with ForceCommand. When ForceCommand is set to internal-sftp for a group of users, the server ignores whatever command the client requested and starts the SFTP service instead. This turns accounts into SFTP-only accounts. The manual also warns that ForceCommand does not by itself limit other kinds of access, such as forwarding, which is why the next steps matter.

Apply these settings inside a Match block that targets a specific group, for example a group you create for partner accounts. That keeps administrator accounts unaffected and makes the partner rules easy to read and audit.

Step 5: Limit who can log in at all

Even if an account exists on the system, it does not have to be allowed to use SSH. AllowUsers and AllowGroups restrict login to the names or groups you list, and the manual states that deny rules take precedence over allow rules.

Use an allow-list approach: create a group for partners, a group for administrators, and allow only those. New local accounts created by software installs or other staff then cannot be used for remote login by accident.

Review the list when partners leave. Removing an account from the group is quicker and safer than hoping someone remembers to delete files and keys later. Make offboarding a documented step in your partner contract and your own checklist.

Step 6: Restrict each key

Key-based login is stronger than passwords, but a key that works from anywhere, for anything, is still a risk if it is copied. OpenSSH lets you add options in front of a public key in the authorized keys file to narrow what it can do.

OptionWhat it doesWhen to use it
restrictTurns on all restrictions at once, disabling port, agent and X11 forwarding, terminal allocation and the user rc fileDefault for every partner key
fromRequires the connection to come from listed hosts or address rangesWhen the partner has fixed addresses
commandRuns a fixed command when the key authenticatesFor single-purpose service keys
expiry-timeStops accepting the key after a given timeTemporary access and contractors
no-port-forwarding / no-ptyBlocks forwarding and terminals for that keyIf you do not use restrict

The manual describes restrict as including any restrictions added in later versions, which makes it a sensible habit. Individual options can re-enable a feature that restrict turned off, but you should not need that for an SFTP-only partner.

Step 7: Switch off forwarding and terminals

An SFTP account should move files and nothing else. Port forwarding lets a user turn the server into a tunnel to other systems, and a terminal lets them run commands. Neither belongs on a partner account.

Combination padlock hanging on a steel cable representing disabled forwarding and locked down access

The manual notes that AllowTcpForwarding is enabled by default. In the partner Match block, set it to no, and disable terminal allocation as well. DisableForwarding is a single setting that disables all forwarding types at once, which can be easier to keep consistent.

These controls matter because an attacker who steals a partner key could otherwise use the server as a stepping stone into your internal network. With forwarding and terminals disabled, a stolen key is limited to the files the account can reach.

Step 8: Reduce guesswork for attackers

Internet-facing SSH servers receive constant automated login attempts. You cannot stop them, but you can limit their value.

  • Lower MaxAuthTries from its default of six, so each connection gets fewer guesses.
  • Rely on keys, which makes password guessing irrelevant.
  • Restrict source addresses at the firewall to partner ranges where you can.
  • Consider rate limiting or a tool that blocks repeated failures, as long as you review it so a legitimate partner is not locked out without anyone noticing.

Changing the SSH port number is sometimes suggested. It reduces log noise but is not a security control, so do not rely on it. Spend the effort on keys, restrictions and monitoring instead.

Step 9: Turn on useful logging and watch it

Hardening without monitoring is only half the job. The manual lists LogLevel as INFO by default and describes VERBOSE as giving more detail, while advising against debug levels because they violate user privacy. For an SFTP server, INFO or VERBOSE is a reasonable range, depending on whether you want to record individual file operations.

Send logs off the machine so an attacker who gains access cannot quietly erase them. NIST SP 800-92 is the federal guide to planning and maintaining log management, and its ideas apply here: decide what to collect, protect it, review it and keep it for a defined period.

  • Alert on repeated failed logins and on logins from unexpected addresses.
  • Alert on a key being used outside its normal schedule.
  • Record administrative changes to accounts and keys.

Our article on secure file transfer audit logs goes deeper on retention and review.

Step 10: Patch, back up and manage keys over time

A hardened server drifts back to risk unless it is maintained. Plan three routines.

  1. Patching: apply operating system and SSH updates on a schedule, and test changes first.
  2. Backups: back up configuration and partner key lists, so rebuilding is fast and deliberate.
  3. Key lifecycle: keep an inventory of every key, who owns it, and when it was last reviewed, and rotate on a schedule.

The OWASP Secrets Management Cheat Sheet recommends regular rotation so that stolen credentials work only for a short time, and tight scoping so each credential reaches only what it needs. Those ideas apply to SSH keys as much as to API tokens. Also verify server identity: RFC 4251 describes comparing host key fingerprints through a separate channel such as a phone call, which you can offer to new partners.

Verify the hardening by testing it

Never assume a setting worked. Test each control as an attacker or a careless partner would.

  1. Try to log in with a password and confirm it is refused.
  2. Try to log in as root and confirm it is refused.
  3. Log in as a partner account and confirm you cannot leave the chroot directory.
  4. Try to open a shell or request a terminal and confirm it is blocked.
  5. Try to forward a port and confirm it fails.
  6. Use a key from a disallowed address and confirm it is rejected.
  7. Check that failed and successful logins appear in the log destination.

Record the results with dates. This simple test record is often the most persuasive evidence you can show a customer or an auditor.

A one-page hardening checklist

Use this summary to review any SFTP server quickly.

ControlTarget stateChecked
Dedicated serviceNo unrelated roles on the hostYes or no
Password loginDisabled for partner accountsYes or no
Root loginDisabledYes or no
ChrootEach partner confined, ownership rules metYes or no
Subsysteminternal-sftp with forced commandYes or no
Login allow-listOnly named groups may connectYes or no
Key restrictionsrestrict plus address and expiry where suitableYes or no
Forwarding and terminalsDisabledYes or no
LoggingSent off-host and reviewedYes or no
MaintenancePatching and key rotation scheduledYes or no

If you manage many partners, consider a platform that applies these rules centrally. Our overview of managed file transfer explains what that adds.

Frequently Asked Questions

For partner-facing servers, key-based login is the stronger default, and password login is usually disabled. If a partner cannot use keys, treat passwords as an exception with a limited account, strong password rules, source address restrictions and monitoring. Review exceptions regularly and retire them as soon as the partner can switch to keys.

The most common cause is ownership. OpenSSH checks that every directory in the chroot path is owned by root and not writable by group or others. If any component fails that check, the session ends. Fix the permissions on the path, then create a separate writable subfolder inside the chroot for uploads.

internal-sftp is an SFTP server built into the SSH daemon that runs in the same process. It does not need extra files copied into a chroot, which keeps jailed setups simpler and smaller. Combined with a forced command, it turns an account into an SFTP-only account that cannot start other programs.

It can reduce automated noise in your logs, but it does not stop a determined attacker, because services are easy to discover. Treat it as optional and cosmetic. Real protection comes from key-only login, restricted keys, source address limits, disabled forwarding, patching and monitoring.

There is no single correct interval, so set one that fits your risk and partner agreements. Rotate immediately when someone leaves, a key may have been exposed, or a contract ends. Otherwise schedule periodic rotation, keep an inventory of key owners, and use expiry options for temporary access.

Test it. Attempt a password login, a root login, leaving the chroot, opening a terminal, forwarding a port and connecting from a disallowed address, and confirm each is refused. Check that your logs recorded the attempts. Keep dated test records, and repeat the tests after upgrades or configuration changes.

Sources and Further Reading

This guide draws on the pages below. Vendor documentation and standards change, so check the current version before relying on a detail.

  1. OpenBSD sshd_config manual page (man.openbsd.org)
  2. OpenBSD sshd manual authorized keys file format (man.openbsd.org)
  3. RFC 4251 The Secure Shell Protocol Architecture (rfc-editor.org)
  4. NIST SP 800-92 Guide to Computer Security Log Management (csrc.nist.gov)
  5. OWASP Secrets Management Cheat Sheet (cheatsheetseries.owasp.org)

Related Articles

SFTP vs FTPS vs HTTPS
Which secure transfer protocol to use
Secure File Transfer Audit Logs
What to record and how long to keep it
Automate Secure File Transfers
Reliable transfers between business systems
Zero Trust for File Sharing
Practical steps for small and mid-size teams
Branded Client Portals Explained
What a branded client portal customizes, from logo and domain to...
Mohamed Siraj

About the Author: Mohamed Siraj

Mohamed is the founder of SecureTools.live. He leads the team in building secure, compliant, and privacy-first directory tooling for software teams, finance professionals, and enterprise security leaders worldwide.

Connect on LinkedIn
Advertise
Advertise
4 of 4 spots left
SecureTools Logo

Practical comparisons, security guidance, verified capabilities, and research for file security and document tools.

Compare tools, understand encryption controls, and choose the right software for your privacy needs.

SOLUTIONS

  • Categories
  • All Tools
  • Open Source
  • Extensions
  • Plugins & MCP
  • Alternatives
  • All Solutions→

PROVIDERS & COMPARISONS

  • Secure File Sharing
  • Encrypted Cloud Storage
  • Virtual Data Rooms
  • Electronic Signatures
  • PDF & Redaction Tools
  • Zero-Knowledge Encryption

RESOURCES

  • Resources & Security Hub
  • Enterprise Security Guide
  • Editorial Standards
  • Security Standards
  • Cryptographic Research
  • File Formats & Specs
  • Blog & Guides
  • Write for Us
  • Contact

POPULAR ARTICLES

  • Bitwarden vs 1Password
  • Cryptomator vs Boxcryptor
  • Nextcloud vs ownCloud
  • What Is Zero-Knowledge?
  • 7-Zip vs PeaZip Guide
  • How to Redact PDFs Safely
ASK AI:Analyze and compare software security tools with prefilled query
ChatGPTChatGPTClaudeClaudePerplexityPerplexityGrokGrok
SecureTools.live on Nick LaunchesVerified DR - Verified Domain Rating for securetools.liveHuzzler Embed BadgeListed on Uno DirectoryLovable App BadgeSecureTools.live | Software Discovery for Files, Documents & Security on StartupTrustedFeatured on DodoDirectoryLaunched on StartupBaseFeatured on TinyShelfVerified on DANG!SecureTools.live — Featured on Smol LaunchFeatured on Days LaunchGood AI ToolsListed on Sell With BoostAcid ToolsFeatured on ToolDirsFeatured on Tool ListFeatured on Sky LaunchSecureTools.live on Nick LaunchesVerified DR - Verified Domain Rating for securetools.liveHuzzler Embed BadgeListed on Uno DirectoryLovable App BadgeSecureTools.live | Software Discovery for Files, Documents & Security on StartupTrustedFeatured on DodoDirectoryLaunched on StartupBaseFeatured on TinyShelfVerified on DANG!SecureTools.live — Featured on Smol LaunchFeatured on Days LaunchGood AI ToolsListed on Sell With BoostAcid ToolsFeatured on ToolDirsFeatured on Tool ListFeatured on Sky Launch
© 2026 SecureTools.live. All rights reserved.
Editorial Policy·Contact·althunt.io@gmail.com·Write for Us·Sitemap·llms.txt

SecureTools.live evaluates and audits software discovery platforms against documented security, privacy, and zero-knowledge criteria.