1. 创建账号及目录
groupadd sftp
useradd -g sftp -s /sbin/nologin -M sftp
passwd sftp
mkdir sftp
chown root:sftp sftp
cd sftp/
mkdir file
chown sftp:sftp file/
chmod a+w sftp -R sftp
chmod 755 sftp
2. 修改ssh配置文件
/etc/ssh/sshd_config
Subsystem sftp /usr/libexec/openssh/sftp-server
Match User sftp
AllowTcpForwarding no
ChrootDirectory /data/sftp #设定属于用户组sftp的用户访问的根文件夹
ForceCommand internal-sftp
X11Forwarding no
3.重启ssh
systemctl restart sshd