• [^] # Re: Plus d'infos

    Posté par . En réponse au message mot de passe psql??? postgresql sous ubuntu. Évalué à 1.

    En fait en ayant tout bien relu et fait des petits test, pour avoir un accès via l'utilisateur postgres sans problème de sécurité, il faut mettre

    local all postgres ident sameuser

    et non

    local all postgres trust

    C'est d'ailleurs la config par défaut.


    Un petit test sur une vm toute propre :
    Debian Lenny, install de postgresql, configuration de pg_hba par défaut :

    local all postgres ident sameuser
    local all all ident sameuser
    host all all 127.0.0.1/32 md5
    host all all ::1/128 md5


    On test en root :

    test:~# psql
    psql: FATAL: Ident authentication failed for user "root"
    test:~# psql template1 -U postgres
    psql: FATAL: Ident authentication failed for user "postgres"
    test:~# psql -U postgres
    psql: FATAL: Ident authentication failed for user "postgres"


    On test en postgres

    postgres@test:/root$ psql
    Welcome to psql 8.3.11, the PostgreSQL interactive terminal.

    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit

    postgres=#



    Je fais la petite modification dans le fichier hba :

    local all postgres ident sameuser
    local all all md5
    local all all ident sameuser
    host all all 127.0.0.1/32 md5
    host all all ::1/128 md5


    On reteste le tout.

    En root :

    test:~# psql
    psql: FATAL: Ident authentication failed for user "root"
    test:~# psql template1 -U postgres
    psql: FATAL: Ident authentication failed for user "postgres"
    test:~# psql -U postgres
    psql: FATAL: Ident authentication failed for user "postgres"




    En postgres

    postgres@test:/root$ psql
    Welcome to psql 8.3.11, the PostgreSQL interactive terminal.

    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help with psql commands
    \g or terminate with semicolon to execute query
    \q to quit

    postgres=#



    On crée et test avec un autre user pour voir :

    toto@test:/root$ psql
    psql: FATAL: Ident authentication failed for user "toto"
    toto@test:/root$ psql template1 -U postgres
    psql: FATAL: Ident authentication failed for user "postgres"
    toto@test:/root$ psql template1
    psql: FATAL: Ident authentication failed for user "toto"



    Voila, pas de problèmes de trou de sécurité ou autre ...
    Je maintiens qu'il n'est pas nécessaire de mettre un mot de passe à l'utilisateur postgres (utilisateur db)