-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
Precautions:
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:
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.