postgresql - Postgres 通过 SSH 进行远程访问,要求输入数据库密码

标签 postgresql ubuntu ssh pgadmin datagrip

Postgres 10 安装在 Ubuntu 18.04 沙箱上

如果我使用 Putty SSH 连接到我的机器,我可以很好地连接到我的数据库。 (VirtualBox 中有 localhost 端口 22 转发)

dangel@ubuntu1804nginx:~$ psql
psql (10.5 (Ubuntu 10.5-0ubuntu0.18.04))
Type "help" for help.

dangel=#

但是,当尝试通过 PGAdmin 或 DataGrip 设置远程连接时,系统会要求我输入数据库用户名和密码...

enter image description here

enter image description here
The specified database user/password combination is rejected: 
[08004] The server requested password-based authentication, but no password was provided

我试过离开 databaseuser字段空白,并填充它们。一样。

这让我感到困惑的原因是,我认为通过 SSH 连接,我应该使用 ident验证?因此不需要密码? (我没有设置密码)(我知道我一定错过了一个简单的概念,但它是什么?)

编辑:
日志文件条目
2018-09-02 03:57:07.865 UTC [13127] dangel@dangel FATAL:  password authentication failed for user "dangel"
2018-09-02 03:57:07.865 UTC [13127] dangel@dangel DETAIL:  User "dangel" has no password assigned.
        Connection matched pg_hba.conf line 94: "host    all             all             ::1/128                 md5"

最佳答案

您的 pg_hba 需要密码才能使用,但用户没有密码,因此无法满足。

在数据库中为数据库用户分配密码(alter user dangel password 'open_sesame'; 或使用 \password psql 命令),或者将“pg_hba.conf”的第 94 行更改为“trust”而不是“md5”。或第三个选项(未经测试),使“常规”选项卡上的“主机”为空字符串,而不是“本地主机”。

您的 psql命令有效,因为这是在 pg_hba 中使用“本地”条目,而不是“主机”条目。如果你想使用 psql要调试这个,那么你需要使用 psql -h localhost ,这将迫使它通过与其他条目相同的 pg_hba 条目。

关于postgresql - Postgres 通过 SSH 进行远程访问,要求输入数据库密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52133749/

相关文章:

database - 仅 1 个数据库的 Postgres 重新分配拥有

php - PostgreSQL - 树组织

postgresql - 具有 read_commited 隔离的 Postgres 死锁

ubuntu - 如何在 Ubuntu Xenial 16.04.4 上获得 Mono 3.5

asp.net-core - 502 Bad Gateway 在 Ubuntu 20.04 上的 NGINX 上运行 ASP .NET Core 5 站点

bash - 通过SSH使用rsync和spawn上传

java - 使用 jOOQ 创建自定义聚合函数

apache - 在 Ubuntu14.04/Apache2/mod_wsgi 上安装 Trac

ssh - 由另一个用户向服务器添加ssh公钥

Git、SSH 和 ProxyCommand