Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Centos7 builds sftp service process

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Note: this tutorial is to build sftp under the root of the website

Create a user group and user, and set the password

Groupadd sftp

Useradd-g sftp-s / bin/false website

Passwd website

Set the home directory of the website user to / var/www/html/uploads/

Usermod-d / var/www/html/uploads/

Edit the configuration file for sftp

Vim / etc/ssh/sshd_config

Modify:

# Subsystem sftp / usr/libexec/openssh/sftp-server # # preceded by a # sign

Add at the end: (if you modify some parts, you don't have to add them)

Subsystem sftp internal-sftp # # specifies the use of sftp services to use the internal-sftp that comes with the system

Match Group sftp # # users who match sftp groups. If you want to match multiple groups, separate them with commas.

ChrootDirectory / var/www/html/uploads/ # # sftp home directory assigned to / var/www/html/upoads/

ForceCommand internal-sftp # # specify sftp command

AllowTcpForwarding no # # users cannot use port forwarding

X11Forwarding no # # users cannot use port forwarding

Set home directory permissions for sftp

Chown root:sftp / var/www/html/uploads/ folder owner must be root, user group may not be root

The permission of chmod 744 / var/www/html / / cannot exceed 755, otherwise it will cause login error, which can be 755.

Restart related services

Systemctl restart sshd.service

Note: so far, the home directory of sftp can only be downloaded and viewed, and cannot be uploaded, deleted or renamed.

Create a test folder under the sftp home directory and set the owner to website and the user group to sftp

Mkdir / var/www/html/uploads/test

Chown website:sftp / var/www/html/uploads/test

Chmod 744 / var/www/html/uploads/test

Restart sshd once

Systemctl restart sshd.service

Note: log in to sftp, divided into linux login and windows login

Linux:sftp website@ip address

Windows: does not come with the sftp command, but only by downloading ftp connection tools, such as xftp, flashfxp, etc.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report