Service Build
CentOS with SSH service, direct configuration can SFTP configuration 1. Create a user group SFTP
Groupadd SFTP
2. Create User
Useradd-g sftp-s/sbin/nologin-d/home/sftp/ftpuser1 ftpuser1
-G Join to SFTP Group
-S Prohibit login
-d The login directory for the specified user 3. Set Password
passwd Ftpuser1
4. Create user ftp file directory
Mkdir/home/sftp/ftpuser1
5. Modify folder owner
Chown-r Ftpuser1:sftp/home/sftp/ftpuser1
6. Modify the SSH configuration file
Modify Sshd_config as follows:
Note the original subsystem settings
#Subsystem Sftp/usr/libexec/openssh/sftp-server
Enable Internal-sftp
subsystem SFTP INTERNAL-SFTP
Restrict user sftp access to root directory
Restricting the root directory of Ftpuser1 users
Match User ftpuser
chrootdirectory/home/sftp
forcecommand internal-sftp
7. Restart SSH service
Systemctl Restart sshd
matters needing attention (pit)
There are two key points to a directory's permissions setting
Directories that are specified by Chrootdirectory to start up to the system root directory owners can only be root
The directory specified by Chrootdirectory is not allowed to have group write permissions to modify file permissions until the system root directory is started
You can use a similar code to modify directory access permissions:
Chmod-r 544/home/sftp/ftpuser1