简体   繁体   English

日志:启动处理期间连接失败:用户=数据库=致命:用户“postgres”的 GSSAPI 身份验证失败

[英]LOG: connection failed during start up processing: user= database= FATAL: GSSAPI authentication failed for user "postgres"

I am trying to configure Kerberos for GSSAPI Currently I have two nodes One the KDC server (windows server 2016) and the the other is Postgres-server(Ubuntu).我正在尝试为 GSSAPI 配置 Kerberos 目前我有两个节点,一个是 KDC 服务器(windows server 2016),另一个是 Postgres-server(Ubuntu)。 I have created Active directory on in kdc-server and create user with the name of postgres and selected the option "password will never expire".我在 kdc-server 上创建了 Active Directory,并创建了名为 postgres 的用户,并选择了“密码永不过期”选项。

Then I have installed a kerbrose client of MIT.然后我安装了 MIT 的 kerbrose 客户端。 here is krb5.ini on kdc server.这是 kdc 服务器上的 krb5.ini。

[libdefaults]
    default_realm = HIGHGO.CA

# The following krb5.conf variables are only for MIT Kerberos.
    kdc_timesync = 1
    ccache_type = 4
    forwardable = true
    proxiable = true

# The following encryption type specification will be used by MIT Kerberos
# if uncommented.  In general, the defaults in the MIT Kerberos code are
# correct and overriding these specifications only serves to disable new
# encryption types as they are added, creating interoperability problems.
#
# The only time when you might need to uncomment these lines and change
# the enctypes is if you have local software that will break on ticket
# caches containing ticket encryption types it doesn't know about (such as
# old versions of Sun Java).

#   default_tgs_enctypes = des3-hmac-sha1
#   default_tkt_enctypes = des3-hmac-sha1
#   permitted_enctypes = des3-hmac-sha1

# The following libdefaults parameters are only for Heimdal Kerberos.
    fcc-mit-ticketflags = true

[realms]
    HIGHGO.CA = {
        kdc = kdc.highgo.ca
        admin_server = kdc.highgo.ca
    }
    ATHENA.MIT.EDU = {
        kdc = kerberos.mit.edu
        kdc = kerberos-1.mit.edu
        kdc = kerberos-2.mit.edu:88
        admin_server = kerberos.mit.edu
        default_domain = mit.edu
    }
    ZONE.MIT.EDU = {
        kdc = casio.mit.edu
        kdc = seiko.mit.edu
        admin_server = casio.mit.edu
    }
    CSAIL.MIT.EDU = {
        admin_server = kerberos.csail.mit.edu
        default_domain = csail.mit.edu
    }
    IHTFP.ORG = {
        kdc = kerberos.ihtfp.org
        admin_server = kerberos.ihtfp.org
    }
    1TS.ORG = {
        kdc = kerberos.1ts.org
        admin_server = kerberos.1ts.org
    }
    ANDREW.CMU.EDU = {
        admin_server = kerberos.andrew.cmu.edu
        default_domain = andrew.cmu.edu
    }
        CS.CMU.EDU = {
                kdc = kerberos-1.srv.cs.cmu.edu
                kdc = kerberos-2.srv.cs.cmu.edu
                kdc = kerberos-3.srv.cs.cmu.edu
                admin_server = kerberos.cs.cmu.edu
        }
    DEMENTIA.ORG = {
        kdc = kerberos.dementix.org
        kdc = kerberos2.dementix.org
        admin_server = kerberos.dementix.org
    }
    stanford.edu = {
        kdc = krb5auth1.stanford.edu
        kdc = krb5auth2.stanford.edu
        kdc = krb5auth3.stanford.edu
        master_kdc = krb5auth1.stanford.edu
        admin_server = krb5-admin.stanford.edu
        default_domain = stanford.edu
    }
        UTORONTO.CA = {
                kdc = kerberos1.utoronto.ca
                kdc = kerberos2.utoronto.ca
                kdc = kerberos3.utoronto.ca
                admin_server = kerberos1.utoronto.ca
                default_domain = utoronto.ca
    }

[domain_realm]
    .mit.edu = ATHENA.MIT.EDU
    mit.edu = ATHENA.MIT.EDU
    .media.mit.edu = MEDIA-LAB.MIT.EDU
    media.mit.edu = MEDIA-LAB.MIT.EDU
    .csail.mit.edu = CSAIL.MIT.EDU
    csail.mit.edu = CSAIL.MIT.EDU
    .whoi.edu = ATHENA.MIT.EDU
    whoi.edu = ATHENA.MIT.EDU
    .stanford.edu = stanford.edu
    .slac.stanford.edu = SLAC.STANFORD.EDU
        .toronto.edu = UTORONTO.CA
        .utoronto.ca = UTORONTO.CA

created principle创造原则

setspn -A postgres/pg.highgo.ca@HIGHGO.CA postgres

after creating principle I have tested it with the following command创建原理后,我使用以下命令对其进行了测试

c:\Users\administrator\Desktop>kinit postgres
Password for postgres@HIGHGO.CA:

which is working fine.这工作正常。

that's how I have created key tab这就是我创建密钥选项卡的方式

ktpass -out pgkt.keytab -princ postgres/pg.highgo.ca@HIGHGI.CA
-mapUser enterprisedb -pass Casper@12 -crypto all -ptype KRB5_NT_PRINCIPAL

and cpoy this file in postgres server and replace it with the file /etc/krb5.keytab with following permission.并在 postgres 服务器中复制此文件,并使用以下权限将其替换为文件 /etc/krb5.keytab。

chmod 600 /etc/krb5.keytab

and here is my /etc/host entries on linux and windows.这是我在 linux 和 windows 上的 /etc/host 条目。

192.168.100.112 pg.highgo.ca
192.168.100.114 kdc.highgo.ca

and I have put an entery in postgress.conf.我在 postgress.conf 中输入了一个条目。

krb_server_keyfile = '/etc/krb5.keytab'

and here is pg_hba.conf entries.这是 pg_hba.conf 条目。

 host     all             all              0.0.0.0/0               gss include_realm=0

after that I have tried to access postgress server with the following command.之后我尝试使用以下命令访问 postgress 服务器。

psql -U postgres -d postgress -h 192.168.100.114

in responce I got the following error on windows.作为回应,我在 windows 上收到以下错误。

psql: error: could not connect to server: SSPI continuation error: The specified target is unknown or unreachable
 (80090303)

and seen the logs on posgtes.并查看了 posgtes 上的日志。

2020-08-18 05:49:36.534 PDT [5086] [unknown]@[unknown] LOG:  connection failed during start up processing: user= database=
2020-08-18 05:49:36.541 PDT [5087] postgres@postgres FATAL:  GSSAPI authentication failed for user "postgress"
2020-08-18 05:49:36.541 PDT [5087] postgres@postgres DETAIL:  Connection matched pg_hba.conf line 97: "host     all             all              0.0.0.0/0               gss include_realm=0 "

I have checked the lots of tutorials but did not get a chance to resolve it.我已经检查了很多教程,但没有机会解决它。

(Note: same commands works fine with MD5 authentication ) (注意:相同的命令适用于 MD5 身份验证)

thanks advance.谢谢提前。

This is a common issue experienced in earlier releases of Postgres and EDB Postgres v. 12, since GSSAPI encryption has been added, but a bug existed.这是早期版本的 Postgres 和 EDB Postgres v.12 中遇到的常见问题,因为已添加 GSSAPI 加密,但存在错误。 The bug has been fixed in commit 79e594cf04754d55196d2ce54fc869ccad5fa9c3 , released in v. 12.3.该错误已在提交 79e594cf04754d55196d2ce54fc869ccad5fa9c3 中修复,在79e594cf04754d55196d2ce54fc869ccad5fa9c3中发布。 If you can upgrade to v. 12.3, you may be able to work around this issue.如果您可以升级到 12.3 版,则可能可以解决此问题。

If you require use of an older client for some reason, please be sure to set gssencmode=disable in your connection string or set PGGSSAPIENCMODE=disable in your environment.如果您出于某种原因需要使用较旧的客户端,请确保在您的连接字符串中设置PGGSSAPIENCMODE=disable gssencmode=disable在您的环境中设置 PGGSSAPIENCMODE=disable。

I have resolve it with the help of my Colleagues this is done on the fresh environment.我在同事的帮助下解决了这个问题,这是在新环境中完成的。 Steps:脚步:

(Note: there no need of kerbrose client on the PG-Server machien (mine is Ubuntu 18.xx)) (注意:PG-Server机器上不需要kerbrose客户端(我的是Ubuntu 18.xx))

  1. Active Directory is setup on Windows 2016 MYDOMAIN.CA and EPAS Server 11 or 12 is installed on both machines. Active Directory 在 Windows 2016 MYDOMAIN.CA 上设置,两台机器上都安装了 EPAS Server 11 或 12。 Active Directory Setup Link活动目录设置链接
  2. Make sure time zone and time on both machines are the same.确保两台机器上的时区和时间相同。
  • /etc/hosts /etc/主机

  • IP of Windows machine is 192.168.100.19 and that of Linux is 192.168.100.17. Windows机器的IP为192.168.100.19,Linux为192.168.100.17。

    Also assuming that Windows machine name is “client” so its full name is “client.mydomain.ca”.还假设 Windows 机器名称是“client”,所以它的全名是“client.mydomain.ca”。

    Enter the following in /etc/hosts on linux (Comment out other entries)在 linux 上的 /etc/hosts 中输入以下内容(注释掉其他条目)

 192.168.100.19 client.mydomain.ca client 192.168.100.17 pg.mydomain.ca pg
  • Enter the following in c:\Windows\System32\Drivers\etc\hosts on Windows在c中输入以下内容:\Windows\System32\Drivers\etc\hosts on Windows
 192.168.100.19 client.mydomain.ca 192.168.100.17 pg.mydomain.ca

Verify the host are communicating with the ping.验证主机是否正在通过 ping 进行通信。

Create User in Active Directory (Windows Machine)在 Active Directory 中创建用户(Windows 机器)

  • Assuming you are logged in as Administrator, In “Server Manager” click “Tools” and select “Active Directory Users and Computers”假设您以管理员身份登录,在“服务器管理器”中单击“工具”和 select“Active Directory 用户和计算机”

  • Under your domain “MYDOMAIN.CA” select users to show all users你的域下“MYDOMAIN.CA” select users 显示所有用户

    Right Click Administrator and select “Copy”右击管理员和select“复制”

  • Enter “pguser” in “First Name” and “User logon name” fields.在“名字”和“用户登录名”字段中输入“pguser”。 Click Next.点击下一步。 Domain “MYDOMAIN.CA” should be shown in combo box against “User logon name”域“MYDOMAIN.CA”应显示在“用户登录名”的组合框中

  • Enter password for user and uncheck “Password never expires” checkbox.输入用户密码并取消选中“密码永不过期”复选框。 -> Click Next -> Click Finish. -> 单击下一步 -> 单击完成。 User account is created.用户帐户已创建。

  • Double click this user in Users list OR right click this user and select Properties.在用户列表中双击此用户或右键单击此用户和 select 属性。

  • In Account Tab, under Account options check “This account supports kerberos AES 256 bit encryption” checkbox and click OK.在帐户选项卡中,在帐户选项下选中“此帐户支持 kerberos AES 256 位加密”复选框,然后单击确定。

  • Log off Windows and login using “pguser” user.注销 Windows 并使用“pguser”用户登录。

Create Keytab创建密钥表

  • Windows Machine: Open Command Prompt as Administrator and enter the following command to create Keytab. Windows 机器:以管理员身份打开命令提示符并输入以下命令以创建 Keytab。
 ktpass -out krb5.keytab -mapUser pguser@MYDOMAIN.CA +rndPass -mapOp set +DumpSalt -crypto AES256-SHA1 -ptype KRB5_NT_PRINCIPAL -princ POSTGRES/pg.mydomain.ca@MYDOMAIN.CA
  • Note that this command should not give any error or warning.请注意,此命令不应给出任何错误或警告。 If you see an error or warning and the keytab is generated, this keytab will not work.如果您看到错误或警告并且生成了密钥表,则此密钥表将不起作用。

  • If the keytab is created successfully, you can check by opening pguser user properties, Account tab that “user logon name” is changed to postgres/pg.mydomain.ca.如果密钥表创建成功,您可以通过打开 pguser 用户属性,帐户选项卡查看“用户登录名”已更改为 postgres/pg.mydomain.ca。

  • Now you have created keytab file “krb5.keytab”.现在您已经创建了密钥表文件“krb5.keytab”。

  • Linux Machine: Copy this file to Linux machine as “/etc/krb5.keytab”. Linux 机器:将此文件作为“/etc/krb5.keytab”复制到 Linux 机器。

//Suppose file is on Desktop of user edb on Linux machine. //假设文件在Linux机器上用户edb的桌面上。 su to become root. su 成为根。

cd /etc/光盘/等/

cp /home/edb/Desktop/krb5.keytab. cp /home/edb/Desktop/krb5.keytab。

chown enterprisedb:enterprisedb krb5.keytab chown enterprisedb:enterprisedb krb5.keytab

chmod 600 krb5.keytab chmod 600 krb5.keytab

  • Open postgresql.conf file and set krb_server_keyfile to “/etc/krb5.keytab” (uncomment this line as it is commented out by default)打开 postgresql.conf 文件并将 krb_server_keyfile 设置为“/etc/krb5.keytab”(取消注释此行,因为它默认被注释掉)

krb_server_keyfile = '/etc/krb5.keytab' krb_server_keyfile = '/etc/krb5.keytab'

  • Open pg_hba.conf file and add the following line (Comment out all other lines except “local all enterprisedb trust/md5” so any remote user can only connect using gss)打开 pg_hba.conf 文件并添加以下行(注释掉除“local all enterprisedb trust/md5”之外的所有其他行,以便任何远程用户只能使用 gss 进行连接)

local all enterprisedb trust本地所有企业数据库信任

host all all 0.0.0.0/0 gss托管所有所有 0.0.0.0/0 gss

  • Restart server.重启服务器。
  • Create user “pguser@MYDOMAIN.CA”.创建用户“pguser@MYDOMAIN.CA”。

CREATE USER "pg1postgres@HIGHGO.CA" SUPERUSER CREATEDB CREATEROLE;创建用户“pg1postgres@HIGHGO.CA” 超级用户已创建DB CREATEROLE;

PSQL command from Windows来自 Windows 的 PSQL 命令

Issue this command to connect to D on Linux发出此命令以连接到 Linux 上的 D

psql -U pgUSER@MYDOMAIN.CA -d edb -h pg.mydomain.ca psql -U pgUSER@MYDOMAIN.CA -d edb -h pg.mydomain.ca

Regards,问候,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pg_dump与数据库“ db_name”的连接失败:致命:用户“ postgres”的对等身份验证失败 - pg_dump connection to database “db_name” failed: FATAL: Peer authentication failed for user “postgres” PostgreSQL: pg_dump: [archiver (db)] 与数据库“dbase”的连接失败:致命:用户“postgres”的对等身份验证失败 - PostgreSQL: pg_dump: [archiver (db)] connection to database "dbase" failed: FATAL: Peer authentication failed for user "postgres" Postgres&Rails –严重:用户密码验证失败 - Postgres & Rails – FATAL: password authentication failed for user psql:致命:用户“postgres”的身份验证失败 - psql: FATAL: Ident authentication failed for user "postgres" PostgreSQL:致命:用户“postgres”的密码身份验证失败 - PostgreSQL: FATAL: password authentication failed for user "postgres" psql:严重:用户“ postgres”的身份验证失败 - psql: FATAL: Ident authentication failed for user “postgres” psql:严重:用户“ postgres”的密码身份验证失败 - psql: FATAL: password authentication failed for user “postgres” 致命:用户 postgres aurora 的密码验证失败 - FATAL: password authentication failed for user postgres aurora 致命:用户“postgres”macos 的密码验证失败 - Fatal: password authentication failed for user "postgres" macos hasura 数据库连接失败并出现错误:用户 postgres 的密码验证失败 - hasura database connection failing with error : password authentication failed for user postgres
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM