sudo cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.backup_manual
[root@ids python_ml]# sudo sed -i '/^local.*ids_database.*ids_user/d' /var/lib/pgsql/data/pg_hba.conf
sudo sed -i '/^host.*ids_database.*ids_user/d' /var/lib/pgsql/data/pg_hba.conf
[root@ids python_ml]# cat << 'EOF' | sudo tee -a /var/lib/pgsql/data/pg_hba.conf
# IDS Database - SCRAM-SHA-256
local   ids_database    ids_user                                scram-sha-256
host    ids_database    ids_user        127.0.0.1/32            scram-sha-256
host    ids_database    ids_user        ::1/128                 scram-sha-256
EOF
# IDS Database - SCRAM-SHA-256
local   ids_database    ids_user                                scram-sha-256
host    ids_database    ids_user        127.0.0.1/32            scram-sha-256
host    ids_database    ids_user        ::1/128                 scram-sha-256
[root@ids python_ml]# systemctl reload postgresql
[root@ids python_ml]# sudo grep "ids_database" /var/lib/pgsql/data/pg_hba.conf
local   ids_database    ids_user                                scram-sha-256
host    ids_database    ids_user        127.0.0.1/32            scram-sha-256
host    ids_database    ids_user        ::1/128                 scram-sha-256
[root@ids python_ml]# export PGPASSWORD="TestPassword123"
[root@ids python_ml]# psql -h ::1 -U ids_user -d ids_database -c "SELECT 1;"
 ?column?
----------
        1
(1 row)

[root@ids python_ml]# pkill -f syslog_parser
[root@ids python_ml]# sudo -u ids nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1 &
[1] 59373
[root@ids python_ml]# tail -20 /var/log/ids/syslog_parser.log
nohup: ignoring input
=== SYSLOG PARSER PER ROUTER MIKROTIK ===
Pressione Ctrl+C per interrompere

[ERROR] Connessione database fallita: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"

[INFO] Disconnesso da PostgreSQL
Traceback (most recent call last):
  File "/opt/ids/python_ml/syslog_parser.py", line 215, in <module>
    main()
  File "/opt/ids/python_ml/syslog_parser.py", line 203, in main
    parser.connect_db()
  File "/opt/ids/python_ml/syslog_parser.py", line 48, in connect_db
    self.conn = psycopg2.connect(**self.db_config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ids/.local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"

[1]+  Exit 1                  sudo -u ids nohup python3.11 syslog_parser.py > /var/log/ids/syslog_parser.log 2>&1
[root@ids python_ml]# tail -20 /var/log/ids/syslog_parser.log
nohup: ignoring input
=== SYSLOG PARSER PER ROUTER MIKROTIK ===
Pressione Ctrl+C per interrompere

[ERROR] Connessione database fallita: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"

[INFO] Disconnesso da PostgreSQL
Traceback (most recent call last):
  File "/opt/ids/python_ml/syslog_parser.py", line 215, in <module>
    main()
  File "/opt/ids/python_ml/syslog_parser.py", line 203, in main
    parser.connect_db()
  File "/opt/ids/python_ml/syslog_parser.py", line 48, in connect_db
    self.conn = psycopg2.connect(**self.db_config)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/ids/.local/lib/python3.11/site-packages/psycopg2/__init__.py", line 122, in connect
    conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL:  password authentication failed for user "ids_user"
