PG之密码检测插件---passwordchecke及延迟

1.下载

https://github.com/Luckyness/passwordcheck.git

2.使用方式

[root@harbor contrib]# cat /data/tools/passwordcheck/README.md
# 1.使用方式
* 替换目录 ../postgresql-11.4/contrib/passwordcheck 下的 passwordcheck.c
* 编译安装 make && make install
* postgresql配置文件内修改 (postgresql.conf)
* shared_preload_libraries = 'passwordcheck'
* passwordcheck.level = 'true'
![](index_files/1abfaa30-e518-48cf-89f4-5bc8ef22df34.png)

# 2.效果
pg数据库用户密码必须包括数字英文和特殊字符

3.使用

#pg_ctl restart

postgres=# alter role postgres encrypted password 'abc123';
ERROR: 22023: password is too short
LOCATION: check_password, passwordcheck.c:102
Time: 0.344 ms
postgres=#

4.密码验证失败延迟

 

(1)防止暴力破解,验证失败后,需要等待一个时间才能继续验证

 

[postgres@harbor auth_delay]$ pwd
/data/tools/postgresql-14.3/contrib/auth_delay

$make && make install

(2)修改配置文件

#vi postgresql.conf 

 

 

shared_preload_libraries = 'auth_delay,passwordcheck'
passwordcheck.level = 'true'
auth_delay.milliseconds = 60000 #(60s)

 

 

[postgres@harbor auth_delay]$ psql -h192.168.56.106 -Upostgres postgres -W
Password:

 

 

密码如果输入错误会等待到60s返回错误结果,防止暴力破解

 

posted @ 2022-09-17 15:35  青空如璃  阅读(527)  评论(0编辑  收藏  举报