認證方法 下面的認證方法可用于 Unix 和 TCP/IP 域套接字: trust 無條件允許聯接。 reject 無條件拒絕聯接。 crypt 客戶端被要求向用戶請求一個口令。該口令被加密后(使用 crypt(3))發送,然后與放在 pg_shadow 表里的口令進行比較。如果口令匹配,則允許聯接。 password 客戶端被要求向用戶請求一個口令。該口令以明文發送,然后與放在 pg_shadow 表里的口令進行比較。如果口令匹配,則允許聯接。可以在 password 關鍵字后面聲明一個可選的文件名,用于提供對應的口令而不是使用 pg_shadow 表里面的。參閱 pg_passwd。 下面的認證方式只能用于 TCP/IP 域套接字: krb4 Kerberos V4 用于認證用戶。 krb5 Kerberos V5 用于認證用戶。 ident 在客戶端的 ident 服務器用于認證該用戶(RFC 1413)。可以在 ident 關鍵字后面聲明一個可選的映射名,這樣允許 ident 用戶名映射成Postgres 用戶名。映射放在文件 $PGDATA/pg_ident.conf 里。 例子 # Trust any connection via Unix domain sockets. local trust # Trust any connection via TCP/IP from this machine. host all 127.0.0.1 255.255.255.255 trust # We don't like this machine. host all 192.168.0.10 255.255.255.0 reject # This machine can't encrypt so we ask for passwords in clear. host all 192.168.0.3 255.255.255.0 password # The rest of this group of machines should provide encrypted passwords. host all 192.168.0.0 255.255.255.0 crypt