AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / dba / 问题

问题[pg-hba.conf](dba)

Martin Hope
Chris Stryczynski
Asked: 2020-07-04 07:50:13 +0800 CST

postgresql 似乎不尊重 pg_hba.conf 配置 - 我该如何诊断?

  • 0

我有以下 pg_hba.conf:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     trust
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

有了上面我假设host all all 127.0.0.1/32 trust将允许来自本地主机的 TCP 连接。然而,情况似乎并非如此

[root@XenonKiloCranberry:~]# psql -U postgres
psql (11.7)
Type "help" for help.

postgres=# \q

[root@XenonKiloCranberry:~]# psql -U postgres -h 127.0.0.1
psql: FATAL:  no pg_hba.conf entry for host "127.0.0.1", user "postgres", database "postgres", SSL off

我哪里错了?

输出select * from pg_hba_file_rules:

line_number | type  | database | user_name | address |                 netmask                 | auth_method | options | error 
-------------+-------+----------+-----------+---------+-----------------------------------------+-------------+---------+-------
           1 | local | {all}    | {all}     |         |                                         | trust       |         | 
           2 | host  | {all}    | {all}     | ::1     | ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff | trust       |         | 
(2 rows)
postgresql pg-hba.conf
  • 1 个回答
  • 922 Views
Martin Hope
xof
Asked: 2019-12-24 00:26:06 +0800 CST

Postgres 身份验证失败:日志引用 pg_hba.conf 中不应存在的“第 90 行”

  • 0

无论我尝试什么设置,我都会不断收到来自外部客户端的连接错误,以及尝试从服务器本身上正在运行的控制台进行连接。

我最后一次尝试与“user_test”进行本地连接:

psql -h /var/run/postgresql -p5433 -U user_test

当我检查 /var/log/postgresql/postgresql-12-db_test.log 上的日志时,日志的最后一行让我感到困惑:为什么日志指的是 pg_hba.conf 中的“第 90 行”?那条线不应该存在???

2019-12-23 00:24:50.620 CET [11398] LOG:  listening on IPv4 address "0.0.0.0", port 5433
2019-12-23 00:24:50.620 CET [11398] LOG:  listening on IPv6 address "::", port 5433
2019-12-23 00:24:50.623 CET [11398] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
2019-12-23 00:24:50.649 CET [11399] LOG:  database system was shut down at 2019-12-23 00:24:50 CET
2019-12-23 00:24:50.654 CET [11398] LOG:  database system is ready to accept connections
2019-12-23 00:25:22.452 CET [11426] user_test@user_test LOG:  provided user name (user_test) and authenticated user name (postgres) do not match
2019-12-23 00:25:22.452 CET [11426] user_test@user_test FATAL:  Peer authentication failed for user "user_test"
2019-12-23 00:25:22.452 CET [11426] user_test@user_test DETAIL:  Connection matched pg_hba.conf line 90: "local   all             all                                     peer"

这是我的设置的摘要:

  1. 在 ubuntu 云服务器上全新安装 postgesql 12
  2. 创建了一个集群“db_test”(与标准安装“main”一起)
  3. 添加角色“admin”并将用户“user_test”分配给集群
  4. 告诉 postgres 监听所有端口(ALTER SYSTEM SET listen_addresses='*';)
  5. 修改 pg_hba.conf (sudo nano /var/lib/postgresql/12/db_test/pg_hba.conf)

该文件当前读取(有许多其他设置都不起作用):

# TYPE  DATABASE USER ADDRESS METHOD
local all user_test trust
hostssl all all 31.164.122.223 md5
  1. 使用以下任一方法重新启动该过程:
postgres@servername:~$ sudo service postgresql@12-db_test restart

或者

pg_ctlcluster 12 db_test start
postgresql pg-hba.conf
  • 1 个回答
  • 234 Views
Martin Hope
user2338823
Asked: 2019-04-23 22:04:04 +0800 CST

基于 postgres 主机的身份验证如何工作?

  • 1

这是以下内容的副本:https ://stackoverflow.com/questions/55804806/how-does-postgres-host-based-authentication-work

(我被要求将此查询转移到 DBA.Stackexchange)

我正在安装需要 Postgresql 的 DSPACE。

请看这个链接:DSPACE INSTALL

它说:

然后通过编辑 pg_hba.conf 并添加以下行来加强安全性:

host dspace dspace 127.0.0.1 255.255.255.255 md5. 

我已经在互联网上阅读了上述线路的工作原理。它需要一个连接类型,后跟数据库名称/用户名,然后是 IP 地址和身份验证方案。

我的问题是:由于 dspace 用户在本地运行,这不应该是本地(代替主机)连接吗?

有人可以逐步告诉我请求进来时会发生什么吗?dspace 用户将使用 md5 提交请求的说明在哪里?

postgresql pg-hba.conf
  • 1 个回答
  • 91 Views
Martin Hope
da99
Asked: 2018-06-29 18:31:09 +0800 CST

为什么PG手册说要在第一次启动服务器之前修改“pg_hba.conf”文件?

  • 3

以下内容来自https://www.postgresql.org/docs/current/static/creating-cluster.html,最初强调before:

或者在运行 initdb 之后但在首次启动服务器之前修改生成的 pg_hba.conf 文件。

手册上这样说是为了防止未经授权的用户访问安全性差的 PG 服务器吗?pg_hba.conf或者在第一次启动服务器之前应该编辑文件的其他原因?

postgresql pg-hba.conf
  • 1 个回答
  • 101 Views
Martin Hope
Pavel Naydenov
Asked: 2017-08-17 05:43:42 +0800 CST

意外的 PostgreSQL 重启

  • 9

我的 PostgreSQL 服务器意外重启并显示以下消息:

2017-08-16 03:44:34 GMT LOG:  received fast shutdown request
2017-08-16 03:44:34 GMT LOG:  aborting any active transactions
2017-08-16 03:44:34 GMT FATAL:  terminating connection due to administrator command
2017-08-16 03:44:34 GMT FATAL:  terminating connection due to administrator command
2017-08-16 03:44:34 GMT LOG:  autovacuum launcher shutting down
2017-08-16 03:44:34 GMT LOG:  shutting down
2017-08-16 03:44:34 GMT LOG:  database system is shut down
2017-08-16 03:46:04 GMT LOG:  incomplete startup packet
2017-08-16 03:46:04 GMT LOG:  database system was shut down at 2017-08-16 03:44:34 GMT
2017-08-16 03:46:04 GMT LOG:  MultiXact member wraparound protections are now enabled
2017-08-16 03:46:04 GMT LOG:  database system is ready to accept connections
2017-08-16 03:46:04 GMT LOG:  autovacuum launcher started

可能是什么原因?

配置细节:

OS: Ubuntu 16.04.1 LTS (Windows Azure VM)
PostgreSQL version: 9.5.8
listen address: * (my bad, but Azure have to block another ports from external access.
                   I didn't enable PG 5432 port for external access) 
HBA config:
local   all             postgres                                ident
host    all             all             127.0.0.1/32            md5
host    all             all             ::1/128                 md5
host    all             all             10.0.0.0/24             md5
host    replication     app_replicator 10.0.0.5/32              md5
local   all             all                                     peer
postgresql pg-hba.conf
  • 3 个回答
  • 14187 Views
Martin Hope
Ashish Gamit
Asked: 2016-11-26 05:55:12 +0800 CST

对于 PostgreSQL 数据库,将远程连接限制为密码

  • 1

我最近在客户的 CentOs 机器上建立了一个 PostgreSQL 数据库。到目前为止,远程访问受到限制。

现在我尝试为我们打开远程连接,在pg_hba.conf.

host    all             all             x.x.x.x/x      trust

连接很好,我们只需提供用户名就可以连接数据库。连接时未提供密码。

现在我们只需要限制对有效凭据的访问。

为此,我已将条目更改为

host    all             all             x.x.x.x/x      md5

并且重启了postgresql服务(我已经重启了多次)。如果我们尝试在没有密码或密码错误的情况下进行连接,则数据库已连接。

我想我做错了什么pg_hba.conf。任何指示出了什么问题?

以下是该文件的内容:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
host    all             all             0.0.0.0/0               trust
# IPv4 remote connections:
host    all             all             x.x.x.x/x      md5
host    all             all             x.x.x.x/x          md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     postgres                                peer
#host    replication     postgres        127.0.0.1/32            ident
#host    replication     postgres        ::1/128                 ident
postgresql pg-hba.conf
  • 1 个回答
  • 2943 Views
Martin Hope
Jin
Asked: 2014-12-02 02:54:58 +0800 CST

连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

  • 314

我正在尝试运行一个发送给我的网站,但这样做之后出现了这个错误

连接到 PostgreSQL 服务器:致命:主机“4X.XXX.XX.XXX”、用户“userXXX”、数据库“dbXXX”没有 pg_hba.conf 条目,C:\xampp\htdocs\xmastool\index.php 中的 SSL 关闭第 37 行

我发现这个答案说我只需要在pg_hba.conf文件中为该特定用户添加一个条目。

这是我的pg_hba.conf文件。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# IPv4 local connections:
local dbXXX userXXX md5
host    dbXXX  userXXX  XX.XXX.XXX.XXX           md5
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
#host    replication     postgres        127.0.0.1/32            md5
#host    replication     postgres        ::1/128                 md5

但这样做之后,错误仍然存​​在。我重新启动了我的 XAMPP 服务器几次,但没有任何变化。

我需要改变pg_hba.conf什么?

postgresql pg-hba.conf
  • 12 个回答
  • 892678 Views
Martin Hope
Ariel Grabijas
Asked: 2013-01-12 11:50:56 +0800 CST

来自 PostgreSQL 的 pg_hba.conf

  • 0

我不知道如何配置该 pg_hba.conf 文件,以通过 pgAdmin 与我的服务器连接。现在我正在尝试添加:

host all all host.name.org.pl trust

host all all host.name.org.pl md5

host user_name database_name ip_adress trust

host all all ip_adress trust/md5

和别的..

我有一个 postgresql 服务器。我的提供商说我必须通过地址连接:sql.user_name.org.pl 和 5432 端口。服务器上没有ssl。我有用户名和密码。有人可以帮我解决这个问题吗?

postgresql pg-hba.conf
  • 1 个回答
  • 1505 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目

    • 12 个回答
  • Marko Smith

    如何让sqlplus的输出出现在一行中?

    • 3 个回答
  • Marko Smith

    选择具有最大日期或最晚日期的日期

    • 3 个回答
  • Marko Smith

    如何列出 PostgreSQL 中的所有模式?

    • 4 个回答
  • Marko Smith

    列出指定表的所有列

    • 5 个回答
  • Marko Smith

    如何在不修改我自己的 tnsnames.ora 的情况下使用 sqlplus 连接到位于另一台主机上的 Oracle 数据库

    • 4 个回答
  • Marko Smith

    你如何mysqldump特定的表?

    • 4 个回答
  • Marko Smith

    使用 psql 列出数据库权限

    • 10 个回答
  • Marko Smith

    如何从 PostgreSQL 中的选择查询中将值插入表中?

    • 4 个回答
  • Marko Smith

    如何使用 psql 列出所有数据库和表?

    • 7 个回答
  • Martin Hope
    Jin 连接到 PostgreSQL 服务器:致命:主机没有 pg_hba.conf 条目 2014-12-02 02:54:58 +0800 CST
  • Martin Hope
    Stéphane 如何列出 PostgreSQL 中的所有模式? 2013-04-16 11:19:16 +0800 CST
  • Martin Hope
    Mike Walsh 为什么事务日志不断增长或空间不足? 2012-12-05 18:11:22 +0800 CST
  • Martin Hope
    Stephane Rolland 列出指定表的所有列 2012-08-14 04:44:44 +0800 CST
  • Martin Hope
    haxney MySQL 能否合理地对数十亿行执行查询? 2012-07-03 11:36:13 +0800 CST
  • Martin Hope
    qazwsx 如何监控大型 .sql 文件的导入进度? 2012-05-03 08:54:41 +0800 CST
  • Martin Hope
    markdorison 你如何mysqldump特定的表? 2011-12-17 12:39:37 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 对 SQL 查询进行计时? 2011-06-04 02:22:54 +0800 CST
  • Martin Hope
    Jonas 如何从 PostgreSQL 中的选择查询中将值插入表中? 2011-05-28 00:33:05 +0800 CST
  • Martin Hope
    Jonas 如何使用 psql 列出所有数据库和表? 2011-02-18 00:45:49 +0800 CST

热门标签

sql-server mysql postgresql sql-server-2014 sql-server-2016 oracle sql-server-2008 database-design query-performance sql-server-2017

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve