在CentOS系统中,您可以使用OpenSSH服务器来设置SFTP访问权限
sudo yum install openssh-server
sudo groupadd sftp_users
sudo useradd -m -G sftp_users your_username
将your_username
替换为您要创建的用户名。系统将提示您设置密码。
/etc/ssh/sshd_config
文件:sudo vi /etc/ssh/sshd_config
在文件末尾添加以下内容:
Match Group sftp_users
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no
这将限制sftp_users组的用户只能访问其主目录,并禁止TCP和X11转发。
保存并退出编辑器。
重启SSH服务以应用更改:
sudo systemctl restart sshd
现在,您已经成功限制了SFTP访问权限。新创建的用户将只能通过SFTP访问其主目录,而无法访问其他用户的文件或系统文件。