From: http://blog.csdn.net/xinxin19881112/article/details/46831311
1. Create an SFTP group
Groupadd SFTP
2, create an SFTP user, the user name is mysftp, password is mysftp
Useradd-g sftp-s/bin/false mysftp // user name // password
3, the user's home directory of the SFTP group is uniformly assigned to/DATA/SFTP, according to the user name, here to create a new mysftp directory, and then specify MYSFTP home for/data/sftp/mysftp
Mkdir-p/data/sftp/mysftp -d/data/sftp/mysftp mysftp
4. Vim opens/etc/ssh/sshd_config
Find the following line, which is commented out with the # symbol, roughly at the end of the file.
Subsystem Sftp/usr/libexec/openssh/sftp-server
Add the following lines to the last side of the file, and then save.
internal-sftp Match Group sftp /data/sftp/%u internal-SFTP allowtcpforwarding No X11forwarding No
5. Set chroot directory Permissions
Chown root:sftp/data/sftp/mysftp 755 /data/sftp/mysftp
6. Create a directory that can be written after the SFTP user log in
After setting up the above, after restarting the SSHD service, the user mysftp can already log in. However, after using Chroot to specify the root directory, the root should be unable to write, so create a new directory for mysftp to upload files. This directory owner is mysftp, all groups are SFTP, the owner has write permissions, and all groups have no write permission. The command is as follows:
mkdir/data/sftp/mysftp/upload /data/sftp/mysftp/upload 755 /data/ Sftp/mysftp/upload
7. Vim Modified/etc/selinux/config
Modify the selinux=enforcing in the file to Selinux=disabled, and then save.
Re-enter command
0
8. Restart the SSHD service
Service sshd Restart
9. Verifying the SFTP environment
Login with mysftp user name, yes OK, enter password.
SFTP [email protected]127.0. 0.1
Display Sftp> The SFTP is successfully built.
10, using FileZilla FTP Client connection sftp server download link: https://filezilla-project.org/download.php?type=client
Enter the host IP address, user name, password, port connection to the SFTP server, the port default is 22.
[FTP] Centos Create SFTP steps