How to Configure CentOS 7.4 SFTP Server

Source: Internet
Author: User
Keywords centos 7 sftp server sftp centos ssh services
Service building
CentOS comes with SSH service, you can configure it directly

SFTP configuration

1. Create user group sftp

groupadd sftp

2. Create a user

useradd -g sftp -s /sbin/nologin -d /home/sftp/ftpuser1 ftpuser1

-g join the sftp group
-s prohibit login
-d specifies the user's login directory

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:

Annotate the original Subsystem settings

#Subsystem sftp /usr/libexec/openssh/sftp-server

Enable internal-sftp
Subsystem sftp internal-sftp

Restrict user SFTP access to the root directory

Restrict the root directory of the ftpuser1 user

Match User ftpuser
ChrootDirectory /home/sftp
ForceCommand    internal-sftp

7. Restart the SSH service

systemctl restart sshd


There are two main points in the permissions setting of the directory

The directory owner from the directory specified by ChrootDirectory up to the system root can only be root
The directory specified by ChrootDirectory cannot go up to the system root directory until the system root directory.

Modify file permissions

You can modify the directory's access permissions using code similar to the following:

chmod -R 544 /home/sftp/ftpuser1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.