【问题标题】:Reposting - Error: Ident authentication failed for user重新发布 - 错误:用户身份验证失败
【发布时间】:2019-12-12 14:36:53
【问题描述】:

我觉得Unix&Linux 的人流量很慢,所以我也在这里发布这个问题:

我在 CentOS 中安装了 Postgres,以及 Node 和 React with NGINX。按照推荐的here,我已经让我的Unix postgres 帐户没有密码。我还使用 postgrator 编写了迁移,它在 blog_database 中创建了一个表为 blog_user

我的blog_user 具有LOGIN 属性和加密密码,并且数据库blog_databasepostgres 所有。

当我在 CentOS 中运行迁移时,我收到此消息

[joseph@vultr backend]$ yarn run migrate
yarn run v1.17.3
$ postgrator --config postgrator-config.js
[2:41:39 AM] table schemaversion does not exist - creating it.
[2:41:39 AM] version of database is: 0
[2:41:39 AM] migrating up to 2
Error: Ident authentication failed for user "blog_user"
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

当尝试将peerall 更改为md5 时,我需要输入postgres 的密码

-bash-4.2$ vim /var/lib/pgsql/11/data/pg_hba.conf 
-bash-4.2$ sudo systemctl restart postgresql.service

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for postgres: 
Sorry, try again.

以 root 身份执行重启命令会导致此消息

[root@vultr ~]# vim /var/lib/pgsql/11/data/pg_hba.conf 
[root@vultr ~]# systemctl restart postgresql.service
Failed to restart postgresql.service: Unit not found.

我不确定我需要做什么来解决这个问题。

【问题讨论】:

  • 我和你一样觉得你的问题没有得到回答,但这并没有超越父亲的规则,即“询问有关特定编程问题、软件算法、编码技术的问题,软件开发工具。”作为一般建议,虽然我喜欢 vultr - 如果您不是经验丰富的系统管理员(抱歉 - 显然您不是):不要重新发明轮子,使用一些服务。例如,您可以拥有一个运行 on DO 的 Postgres 集群,并配备一个备用节点,每月只需 50 美元。
  • @MarkusWMahlberg 谢谢你的建议。我很感激。不过我已经准备好迎接挑战了,用很多技术把我打败是可以的,我会学习的。
  • 这不是重点。没有监督,你可能会犯一个严重的错误。在最好的情况下,这只会炸毁一些东西。在最坏的情况下,您会泄漏数据。在某些司法管辖区,这使您承担个人责任 - 包括但不限于损害和赔偿。如果你真的需要,我建议在 CentOS 上使用带有 (!) fail2ban(!) 的 docker。并了解如何在上线之前正确更新您的应用程序堆栈。这应该会给你一个不错的设置和基本的安全性。
  • 作为初学者:我创建了一个role for ansible which configures an openssh server to be properly secured(据我所知和我信任的一位专家)
  • 这个比较可能有点短,但如果一个人逍遥法外并不意味着你希望所有凶手都逍遥法外,对吗? ;)

标签: node.js postgresql centos


【解决方案1】:
  1. 对本地连接使用trust 身份验证,除非您的计算机上有不受信任的操作系统用户。

  2. PostgreSQL 服务可能有不同的名称。试试

    systemctl status | grep postgres
    

【讨论】:

  • 我可以确认设置为 trust 或 md5 有效。事实证明,找到正确的服务名称是我的主要问题,叹息。谢谢!
猜你喜欢
  • 2015-12-01
  • 2023-04-04
  • 1970-01-01
  • 2017-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-20
相关资源
最近更新 更多