diff --git a/attached_assets/Pasted--fix-postgresql-auth-sh-PostgreSQL-Authentic-1763396674149_1763396674149.txt b/attached_assets/Pasted--fix-postgresql-auth-sh-PostgreSQL-Authentic-1763396674149_1763396674149.txt new file mode 100644 index 0000000..a5ee042 --- /dev/null +++ b/attached_assets/Pasted--fix-postgresql-auth-sh-PostgreSQL-Authentic-1763396674149_1763396674149.txt @@ -0,0 +1,111 @@ +./fix_postgresql_auth.sh + +╔═══════════════════════════════════════════════╗ +║ PostgreSQL Authentication Fix ║ +╚═══════════════════════════════════════════════╝ + + File pg_hba.conf: /var/lib/pgsql/data/pg_hba.conf + + Backup configurazione... +✅ Backup salvato: /var/lib/pgsql/data/pg_hba.conf.backup_20251117_171950 + + Configurazione ATTUALE: +local all all peer +host all all 127.0.0.1/32 scram-sha-256 +host all all ::1/128 scram-sha-256 +local replication all peer +host replication all 127.0.0.1/32 ident +host replication all ::1/128 ident +local ids_database ids_user md5 +host ids_database ids_user 127.0.0.1/32 md5 + + Modifico pg_hba.conf... +✅ Configurazione modificata + + Configurazione NUOVA: +local all all peer +host all all 127.0.0.1/32 scram-sha-256 +host all all ::1/128 scram-sha-256 +local replication all peer +host replication all 127.0.0.1/32 ident +host replication all ::1/128 ident +local ids_database ids_user md5 +host ids_database ids_user 127.0.0.1/32 md5 + + Ricarico configurazione PostgreSQL... +✅ PostgreSQL ricaricato + +離 Test connessione con password... +❌ Connessione FALLITA + Verifica password in /opt/ids/.env +[root@ids deployment]# systemctl restart postgresql +[root@ids deployment]# psql -h localhost -U ids_user -d ids_database -c "SELECT 1;" +psql: error: FATAL: password authentication failed for user "ids_user" +[root@ids deployment]# sudo -u postgres psql -c "ALTER USER ids_user WITH PASSWORD 'fuvX7Lk7gVNbW72bj81kfU/m6VV+j3SQ8w09z16W1CE=';" +ALTER ROLE +[root@ids deployment]# psql -h localhost -U ids_user -d ids_database -c "SELECT 1;" +psql: error: FATAL: password authentication failed for user "ids_user" +[root@ids deployment]# ./fix_postgresql_auth.sh + +╔═══════════════════════════════════════════════╗ +║ PostgreSQL Authentication Fix ║ +╚═══════════════════════════════════════════════╝ + + File pg_hba.conf: /var/lib/pgsql/data/pg_hba.conf + + Backup configurazione... +✅ Backup salvato: /var/lib/pgsql/data/pg_hba.conf.backup_20251117_172100 + + Configurazione ATTUALE: +local all all peer +host all all 127.0.0.1/32 scram-sha-256 +host all all ::1/128 scram-sha-256 +local replication all peer +host replication all 127.0.0.1/32 ident +host replication all ::1/128 ident +local ids_database ids_user md5 +host ids_database ids_user 127.0.0.1/32 md5 + + Modifico pg_hba.conf... +✅ Configurazione modificata + + Configurazione NUOVA: +local all all peer +host all all 127.0.0.1/32 scram-sha-256 +host all all ::1/128 scram-sha-256 +local replication all peer +host replication all 127.0.0.1/32 ident +host replication all ::1/128 ident +local ids_database ids_user md5 +host ids_database ids_user 127.0.0.1/32 md5 + +🔄 Ricarico configurazione PostgreSQL... +✅ PostgreSQL ricaricato + +🧪 Test connessione con password... +❌ Connessione FALLITA + Verifica password in /opt/ids/.env +[root@ids deployment]# export PGPASSWORD='fuvX7Lk7gVNbW72bj81kfU/m6VV+j3SQ8w09z16W1CE=' +[root@ids deployment]# psql -h localhost -U ids_user -d ids_database -c "SELECT 1;" +psql: error: FATAL: password authentication failed for user "ids_user" +[root@ids deployment]# TEST_PASS="TestPassword123" +[root@ids deployment]# sudo -u postgres psql -c "ALTER USER ids_user WITH PASSWORD '$TEST_PASS';" +ALTER ROLE +[root@ids deployment]# sudo -u ids sed -i "s/PGPASSWORD=.*/PGPASSWORD=$TEST_PASS/" /opt/ids/.env +[root@ids deployment]# grep PGPASSWORD /opt/ids/.env +PGPASSWORD=TestPassword123 +[root@ids deployment]# export PGPASSWORD="$TEST_PASS" +[root@ids deployment]# psql -h localhost -U ids_user -d ids_database -c "SELECT 1;" +psql: error: FATAL: password authentication failed for user "ids_user" +[root@ids deployment]# tail -30 /var/lib/pgsql/data/log/postgresql-*.log | grep -i "ids_user" +2025-11-17 17:19:50.207 CET [59081] DETAIL: User "ids_user" does not have a valid SCRAM secret. +2025-11-17 17:20:26.379 CET [59126] FATAL: password authentication failed for user "ids_user" +2025-11-17 17:20:26.379 CET [59126] DETAIL: User "ids_user" does not have a valid SCRAM secret. +2025-11-17 17:20:51.102 CET [59132] FATAL: password authentication failed for user "ids_user" +2025-11-17 17:20:51.102 CET [59132] DETAIL: User "ids_user" does not have a valid SCRAM secret. +2025-11-17 17:21:00.789 CET [59154] FATAL: password authentication failed for user "ids_user" +2025-11-17 17:21:00.789 CET [59154] DETAIL: User "ids_user" does not have a valid SCRAM secret. +2025-11-17 17:22:28.055 CET [59160] FATAL: password authentication failed for user "ids_user" +2025-11-17 17:22:28.055 CET [59160] DETAIL: User "ids_user" does not have a valid SCRAM secret. +2025-11-17 17:23:42.513 CET [59171] FATAL: password authentication failed for user "ids_user" +2025-11-17 17:23:42.513 CET [59171] DETAIL: User "ids_user" does not have a valid SCRAM secret. \ No newline at end of file