Re: Postgre Userzugriffe

From: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
To: debian-user-german(at)lists(dot)debian(dot)org, <pgsql-de-allgemein(at)postgresql(dot)org>, <pgusers(at)postgres(dot)de>
Subject: Re: Postgre Userzugriffe
Date: 2005-04-19 18:52:28
Message-ID: 87wtqyk39v.fsf@gate450.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-de-allgemein

("xpost" nach pgsql-de-allgemein(at)postgresql(dot)org und
pgusers(at)postgres(dot)de, da der OP die Frage dort ebenfalls gestellt hat)

Henning Follmann schrob:

> On Sun, Apr 17, 2005 at 03:02:53PM +0200, Frank Habermann wrote:
>> host all all 127.0.0.1 255.255.255.255 trust
>>
>> wenn ich mir nun die doku schnappe interpretiere ich die zeile so:
>> alle user können von localhost zugreifen ohne das sie ein passwort
>> brauchen(zugriff über tcp)

> Die pg_hba.conf legt die zugriffsrechte fest mit der das Client Programm
> auf den Prozess zugreifen kann.
> Wenn Du willst, dass der db Nutzer sich authentifizieren muss musst Du
> natuerlich die Zugriffsrechte in der DB anpassen.
> Dass geschieht mit dem Befehl "alter user"
> Die Verwendung des Befehls kannst Du Dir mit \h alter user anzeigen
> lassen.
> Als Beispiel:
> ALTER USER frank WITH PASSWORD 'frankspassword';
>
> Jetzt muesste sich der user frank mit dem password frankspassword
> anmelden.

AFAIK wird, wenn in der pg_hba.conf "trust" steht, garkeine
Authentifizierung verlangt; unabhängig davon, ob ein Passwort für den
User gesetzt ist:

--8<---------------cut here---------------start------------->8---
$ initdb data/
$ echo host all all 127.0.0.1/32 trust > data/pg_hba.conf
$ pg_ctl -D data/ -o -p6666 start
$ psql -h 127.0.0.1 -p 6666 template1
Welcome to psql 8.1devel, 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

template1=# alter user andreas with password 'foo';
ALTER USER
template1=# \q
$ psql -h 127.0.0.1 -p 6666 template1
Welcome to psql 8.1devel, 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

template1=# \q
--8<---------------cut here---------------end--------------->8---

Erst nachdem in der pg_hba.conf explizit Passwort-Authentifizierung
verlangt ist, wird es auch abgefragt:

--8<---------------cut here---------------start------------->8---
$ echo host all all 127.0.0.1/32 password > data/pg_hba.conf
$ pg_ctl -D data/ -o -p6666 restart
$ psql -h 127.0.0.1 -p 6666 template1
Password:
Welcome to psql 8.1devel, the PostgreSQL interactive terminal.
[...]
--8<---------------cut here---------------end--------------->8---

HTH
Andreas

Browse pgsql-de-allgemein by date

  From Date Subject
Next Message Frank Habermann 2005-04-19 19:05:53 Re: User Zugriffe ueber tcp
Previous Message Andreas Seltenreich 2005-04-19 16:39:43 Re: CSV Import