admin管理员组

文章数量:1632155

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 #设置其他用户写入权限。

本文标签: 目录用户LinuxCENTOS