centos7用户权限设置

来源:互联网 发布:淘宝评论禁止词汇 编辑:程序博客网 时间:2024/06/06 01:52

1、 sudo权限添加,编辑修改/etc/sudoers配置文件,在root   ALL=(ALL)     ALL下,添加要加sudo权限的账号。

2、改ssh远程端口:编辑vi /etc/ssh/sshd_config找到#Port 22一段,修改为如下:Port 22 ,把Port后的22改成    你要改的端口号(比如8080),然后保存退出,重启sshd服务(systemctl restart sshd.service)。再在          etc/sysconfig/iptables,中把原来的端口22,改成sshd_config中port的端口号,保存重启iptables服务   (systemctl restart iptables.service)。

3、为了安全,不让root用远程方式登陆系统,编辑#vi /etc/ssh/sshd_config,找到PermitRootLogin yes改为        PermitRootLogin no,保存退出,重启sshd服务(systemctl restart sshd.service)

4、限制非wheel组用户,不能使用su命令。

   编辑/etc/pam.d/su文件,添加auth            required        /usr/lib64/security/pam_wheel.so   use_uid

                                                     auth            sufficient       /usr/lib64/security/pam_rootok.so  debug
                                                     auth            required       /usr/lib64/security/pam_wheel.so group=wheel

                    (说明:这三个文件的路径是centos7下的,其他版本请自行查找),

       修改/etc/login.defs文件,在最后添加SU_WHEEL_ONLY yes。
    将新添加的普通用户添加的wheel组中,命令usermod -G wheel 用户名

0 0
原创粉丝点击