服务器 / mysql 之口令复杂度

数据库、服务器未配置口令复杂度策略

OS
    系统编辑文件/etc/pam.d/system-auth,是否存在如下配置:( 尝试三次,必须包含数字,包含小写字母,包含大写字母,长度至少为8 )
    password requisite  pam_cracklib.so try_first_pass retry=3 dcredit=-1 lcredit=-1 ucredit=-1 ocredit=-1 minlen=8
    
Mysql
   show variables like 'plugin_dir';
   show plugins;
   安装密码插件
   install plugin validate_password soname 'validate_password.so';
   密码策略参数
   mysql>show variables like 'validate%';
    
   #永久生效
  [mysqld]
   plugin-load-add=validate_password.so
   #服务器在启动时加载插件,并防止在服务器运行时删除插件。
   validate-password=FORCE_PLUS_PERMANENT

   卸载插件
   uninstall plugin connection_control_failed_login_attempts

数据库、服务器未配置口令有效期策略

OS
 查看文件/etc/login.defs( more /etc/login.defs),检查如下参数值是否满足要求:
 PASS_MAX_DAYS   90        #新建用户的密码最长使用天数不大于90
 PASS_MIN_DAYS    10        #新建用户的密码最短使用天数为10
 PASS_WARN_AGE   7         #新建用户的密码到期提前提醒天数为7

mysql 
 alter user 'root'@'%' password expire interval 90 day;

服务器、数据库未配置登录失败处理及连接超时自动退出策略。

 
OS
    编辑文件/etc/pam.d/system-auth
    auth required pam_tally2.so deny=5 onerr=fail no_magic_root unlock_time=180
    
mysql
    #登录错误次数限制插件
    install plugin connection_control soname "connection_control.so";
    #为了把错误次数记录到表中
    install plugin connection_control_failed_login_attempts soname 'connection_control.so';
    #设置策略
    set global connection_control_failed_connections_threshold = 5;
    set global connection_control_max_connection_delay = 1800000;
    set global connection_control_min_connection_delay = 1800000;
    #永久生效
    [mysqld]
    plugin-load-add = connection_control.so
    connection-control = FORCE
    connection-control-failed-login-attempts = FORCE
    connection_control_min_connection_delay = 1000
    connection_control_max_connection_delay = 86400
    connection_control_failed_connections_threshold    = 3

 

posted @ 2023-08-12 15:18  黑羽小白  阅读(188)  评论(0)    收藏  举报