Recently to the server to set up a SFTP user, you can upload delete modified sftp, but prohibit the user SSH login. Record here, upgrade first .
Yum Update
Fox Wind. Create a user group SFTP
User group name is SFTP
Groupadd SFTP
Create user Test
For example, this user name is test
-s prevents users from SSH landing
-G join SFTP user group create password
Modify configuration file Sshd_config
Vim/etc/ssh/sshd_config
Modified to read as follows
....
# #下面这行注释掉
#Subsystem sftp/usr/libexec/openssh/sftp-server
# #后面加入
subsystem sftp internal-sftp
#注意 , the following will be placed in the last line of this file, otherwise the root user will not be able to login
Match Group sftp
x11forwarding no
allowtcpforwarding no
chrootdirectory %h
Forcecommand internal-sftp
Description
Match Group SFTP matches users in SFTP user group
Chrootdirectory%h can only access the default User directory (its own directory), such as/home/test set directory Permissions
Chown root:sftp/home/test
chgrp-r sftp/home/test
chmod-r 755/home/test
#设置用户可以上传的目录, Change directory to allow users to upload delete modify files and folders
mkdir/home/test/upload
chown-r test:sftp/home/test/upload
chmod-r 755/home/ Test/upload
reboot ssh
Systemctl Restart Sshd.service
links
Create a new terminal link, or use the SFTP mode link in the FTP client (enter the associated IP username and port)
SFTP test@192.1.1.1
f&q
If the report is similar to the following error
SFTP Connection to closed by remote host.
or
Write Failed:broken pipe
This is the user root directory permissions problem, Chown root:sftp/home/test set to root can be resolved, directory permissions of 755
Other, detect/etc/selinux/config SELinux is selinux=disabled, if not please correct
Reference: http://blog.csdn.net/dodott/article/details/50945888
Https://linux.cn/article-3692-1.html