在CentOS系统中,配置SFTP的目录权限需要遵循以下步骤:
sudo yum install openssh-server
sudo systemctl start sshd
sudo systemctl enable sshd
sudo adduser your_username
sudo passwd your_username
sudo mkdir /home/your_username/sftp
sudo chown your_username:your_username /home/your_username/sftp
sudo chmod 755 /home/your_username/sftp
这里,我们将目录的所有权设置为新创建的用户,并允许用户读取、写入和执行目录中的文件。其他用户只能读取和执行。
sudo vi /etc/ssh/sshd_config
在文件末尾添加以下内容:
Match User your_username
ChrootDirectory /home/your_username/sftp
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
将your_username
替换为实际用户名。这将限制SFTP用户访问指定的目录,并禁止TCP和X11转发。
sudo systemctl restart sshd
现在,SFTP用户应该只能访问/home/your_username/sftp
目录,并具有适当的权限。