等保mysql5.7身份鉴别插件validate_password和Connection-Control

a)应对登录的用户进行身份标识和鉴别,身份标识具有唯一性,身份鉴别信息具有复杂度要求并定期更换;

b)应具有登录失败处理功能,应配置并启用结束会话、限制非法登录次数和当登录连接超时自动退出等相关措施;

mysql>show variables like 'validate_password%';

mysql>show variables like 'connection_control%';

若无任何相关输出说明没有安装插件validate_password和Connection-Control,需要安装,然后合理设置参数。

查看插件位置,mysql5.7插件库里面自带的有,可以确认下

mysql>show variables like 'plugin_dir';

[root@localhost ~]# ll /usr/lib64/mysql//plugin/

直接安装

mysql> install plugin validate_password soname 'validate_password.so';

mysql> install plugin connection_control soname 'connection_control.so';

mysql> install plugin connection_control_failed_login_attempts soname 'connection_control.so';

查看默认配置

show variables like 'validate_password%';

其中:

validate_password_length                                     #口令长度的长度(这个值最小要是4);

validate_password_number_count                        #口令中数字的最小个数;

validate_password_mixed_case_count                  #大小写的最小个数;

validate_password_policy                                     #0对应low  1对应MEDIUM  2对应strong;

validate_password_special_char_count                #特殊字符的最小个数。

想要更改可以全局设置,如

mysql> set global validate_password_length=12;

mysql> set global validate_password_mixed_case_count=1;

mysql> set global validate_password_number_count=1;

mysql> set global validate_password_special_char_count=1;

mysql> set global validate_password_policy=1;


show variables like 'connection_control%';

其中:

connection_control_failed_connections_threshold    #允许验证的次数,默认3次,0不开启

connection_control_max_connection_delay            #失败达上限后最大延迟登录时间,默认约25天  单位:毫秒

connection_control_min_connection_delay            #失败达上限后最小延迟登录时间,默认1s      单位:毫秒

想要更改可以全局设置,如

mysql> set global connection_control_failed_connections_threshold = 3;

mysql> set global connection_control_max_connection_delay = 86400;

mysql> set global connection_control_min_connection_delay = 1000;


不想用了可以卸载插件

mysql> uninstall plugin validate_password;

mysql> uninstall plugin connection_control;


另外其他的设置

查看口令有效期

show variables like 'default_password_lifetime%';

全局设置口令有效期

mysql> set global default_password_lifetime=90;

针对某个用户设置,如'root'@'localhost'用户

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

错误登录失败次数和连接超时

show variables like '%max_connect_errors%';

show variables like '%timeout%';

mysql> set global max_connect_errors = 3;(次)

mysql> set global wait_timeout = 300;(秒)

查看空口令用户

5.7之前

select * from mysql.user where length(password)= 0 or password is null;

5.7之后password为authentication_string

select * from mysql.user where length(authentication_string)= 0 or authentication_string is null;