Centos 7 Set SFTP

Source: Internet
Author: User
Tags chmod ftp client ssh

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

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: info-contact@alibabacloud.com 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.