This commit is contained in:
Igor I
2025-02-21 12:59:15 +05:00
parent af89e9bdea
commit 5bf274751f
2 changed files with 68 additions and 35 deletions

68
PostgreSQL_credcheck.md Normal file
View File

@ -0,0 +1,68 @@
****************************************************************************************************
Установка и настройка проверялщика паролей credcheck
PostgreSQL https://www.postgresql.org/about/news/credcheck-v200-released-2654/
Подключаемся к инфраструктуре потом подключаюсь к нужной машине:
```sh
ssh ivanov.i@10.201.1.6 -p 22
```
```sh
ssh administrator@10.201.1.6 -p 22
```
Тестовая база
```sh
ssh administrator@10.201.3.36 -p 22
```
Похоже в официальном репозитории нет credcheck, так что если будем искать то не найдём:
```sh
apt search credcheck
```
Поэтому устанавливаем из репозиториев (компилируем на тестовой машине потом устанавливаем на продакшен):
```sh
sudo apt-get install postgresql-server-dev-16 &&
sudo apt-get install build-essential &&
git clone https://github.com/HexaCluster/credcheck.git &&
cd credcheck &&
make &&
sudo make install
```
Подключаемся к базе данных для выполнения запросов
```sh
psql -h 127.0.0.1 -U postgres -d transit
```
Проверяем что настройки имеются:
```sh
SELECT name, setting, unit, source, sourcefile, sourceline
FROM pg_settings
WHERE name LIKE 'credcheck%';
```
Читаем текущие настройки
```sh
SHOW ALL;
```
Создаём расширение в базе postgres:
```sh
CREATE EXTENSION credcheck;
```
Теперь можно настроить расширение по https://tembo.io/docs/getting-started/postgres_guides/extensions/credcheck:
-- Configure credential policies to enforce username and password standards and reload configuration files
ALTER SYSTEM SET credcheck.username_min_length = 4;
ALTER SYSTEM SET credcheck.password_min_length = 8;
ALTER SYSTEM SET credcheck.password_min_special = 1;
SELECT pg_reload_conf();
-- Attempt to create a user for a new park ranger, which does not meet the credential policies
CREATE USER ranger_ WITH PASSWORD 'forest';
ERROR: password length should match the configured credcheck.password_min_length
Для пароля установить:
ALTER SYSTEM SET credcheck.password_expiration_days = 90;
SELECT pg_reload_conf();
Для приложений нужно изменить политику паролей (менять не автоматически а по расписанию у администратора):

View File

@ -1014,41 +1014,6 @@ WantedBy=multi-user.target
****************************************************************************************************
Для добавления TOTP авторизации в Postgresql выполнить:
CREATE EXTENSION otp;
****************************************************************************************************
Проверка паролей Gcredcheck и многое другое для PostgreSQL https://www.postgresql.org/about/news/credcheck-v200-released-2654/
Ищем есть ли:
apt search credcheck
Устанавливаем:
sudo apt update
sudo apt install postgresql-16-credcheck
Либо из репозиториев:
sudo apt-get install postgresql-server-dev-16 # Для PostgreSQL 16
sudo apt-get install build-essential
git clone https://github.com/2ndQuadrant/credcheck.git
cd credcheck
make
sudo make install
Теперь можно исползовать расширение на базе postgres:
CREATE EXTENSION credcheck;
Теперь можно настроить расширение по https://tembo.io/docs/getting-started/postgres_guides/extensions/credcheck:
-- Configure credential policies to enforce username and password standards and reload configuration files
ALTER SYSTEM SET credcheck.username_min_length = 4;
ALTER SYSTEM SET credcheck.password_min_length = 8;
ALTER SYSTEM SET credcheck.password_min_special = 1;
SELECT pg_reload_conf();
-- Attempt to create a user for a new park ranger, which does not meet the credential policies
CREATE USER ranger_ WITH PASSWORD 'forest';
ERROR: password length should match the configured credcheck.password_min_length
Для пароля установить:
ALTER SYSTEM SET credcheck.password_expiration_days = 90;
SELECT pg_reload_conf();
Для приложений нужно изменить политику паролей (менять не автоматически а по расписанию у администратора):
****************************************************************************************************