admin管理员组文章数量:1632058
1,添加用户
useradd -d /var/www user1
passwd user1 #设置密码
2,修改sshd_config,使用 chroot 监狱限制 SSH 用户访问指定目录
vim /etc/ssh/sshd_config
#文件最后添加如下代码
Match User user1
ChrootDirectory /var/www
X11Forwarding no
AllowTcpForwarding no
ForceCommand internal-sftp #指定sftp命令,ssh不可以登录
如果配置文件最后有以下配置项,请做修改,否则sshd服务重启会失败
#UseDNS no #注释掉
#AddressFamily inet #注释掉
PermitRootLogin yes
#SyslogFacility AUTHPRIV #注释掉
PasswordAuthentication yes
3,重启sshd服务
systemctl restart sshd
成功重启后,该用户user1不能用ssh连接,filezilla和Xftp连接后只能访问指定目录.
4,设定用户对指定目录进行权限控制
chown设定目录所有者,容易权限混乱,造成ftp不能登录。
chmod o+w /var/www #设置其他用户写入权限。
版权声明:本文标题:linux(centos)限定用户只能访问默认目录,linux(centos) 限制用户访问指定目录 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1729106613a1186882.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论