Use the system's own internal-sftp to build an SFTP server in the CentOS 6.6 environment.
Open the Command Terminal window and follow the steps below.
0. View OpenSSH version
Use the SSH-V command to view the version of OpenSSH, the version must be greater than 4.8P1, and the version below will need to be upgraded.
1. Create an SFTP group
2, create an SFTP user, the user name is mysftp, password is mysftp
Modifying the user password is the same as modifying the Linux user password.
Useradd-g sftp-s/bin/false mysftp//user name
passwd mysftp//password
12 |
useradd-g sftp -s /bin/falsemysftp passwdmysftp |
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
12 |
mkdir-p /data/sftp/mysftp usermod-d /data/sftp/mysftpmysftp |
4, Configuration Sshd_config
Text Editor 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.
1 23456 |
subsystem sftp internal-sftp match group sftp chrootdirectory /data/sftp/%u forcecommand internal-sftp allowtcpforwarding no x11forwarding no |
5. Set chroot directory Permissions
12 |
chownroot:sftp /data/sftp/mysftpchmod755 /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:
123 |
mkdir/data/sftp/mysftp/upload chown mysftp:sftp/data/sftp/mysftp/upload chmod755 /data/sftp/mysftp/upload |
7, modify the/etc/selinux/config
Text Editor opens/etc/selinux/config
Modify the selinux=enforcing in the file to Selinux=disabled, and then save.
In the Enter command
8. Restart the SSHD service
Enter the command to restart the service.
9. Verifying the SFTP environment
Login with mysftp user name, yes OK, enter password.
Display Sftp> The SFTP is successfully built.
This article title: Linux Centos 6.6 Build SFTP Server
From Amoy code reprint please specify
Linux Centos 6.6 Build SFTP Server