
The chroot directory *and all of its parents* must not have group or world write capabilities, otherwise SFTP log in will fail with fatal: bad ownership or modes for chroot directory component “/var/(not 775, which gives group write permissions).For example, by default /var/then your chroot is /var/ The chroot is usually the directory above your document root. SFTP is very strict when it comes to chroot directory permissions and if they are not set correctly, you will not be able to log in, so please follow these instructions carefully. If you are already logged in as this user in your FTP client, close the program completely and then log in again. Note: Linux groups do not take affect until the user logs out and in again. We can do this by adding a Match User directive in the SSH config file. Restrict the user webdev to the document root and also disable their SSH access – we only want them to be able to log in over SFTP. Using this method with the least amount of configuration, we will create a Match User directive in the SSH config and add your SFTP user to the Add Match User Directive in SSH Config You already have your CMS such as WordPress installed and running, and now want to lock it down.You want the best security possible for your document root.Method Two: Better Security and SFTP User Management.You just want a quick and simple method to give one or multiple SFTP users access to the document root by adding them to the You need to install a CMS from scratch such as WordPress before setting up more restrictive permissions in Method Two.It might be worth reading through both methods to see which one suits your needs. I am providing two different methods in this guide because there are some people who just want a quick and easy method to access the document root with SFTP, and others who want a more advanced security setup (which I use). Generate a password and press enter to accept all defaults. SFTP is built upon the SSH transport layer and should be installed on most Linux server distributions by default. This article also includes a section for WordPress users and best security practices.

Regardless of the method you choose, Step 1, 2 and 3 below are the same. Method One is a simple setup where you just add your SFTP user to the I have included a special section for WordPress users and best security practises.If you are using CentOS, just substitute I have provided two different methods in this guide for setting up SFTP access to your document root:

This guide was tested on Ubuntu Server 20.04, 18.04 and 16.04, though it should also work with other Debian-based distributions without issue.

This guide assumes your web document root is the default for Apache and Nginx in /var/Just make sure you have the correct document root and update commands in this guide to match.
