如何使用Kerberos连接到Postgres
我有使用Kerberos身份验证的Postgres DB。因此,我配置了我的/etc/krb5.conf
文件,运行kinit
现在可以使用它,例如在Python代码中:
import psycopg2
conn = psycopg2.connect(
host="database.address.com",
database="tested",
user="username",
port=5472
)
# Get version
cursor = conn.cursor()
cursor.execute('SELECT VERSION()')
row = cursor.fetchone()
print(row)
它可以完美地工作,但是有时它非常有用有能力在表中观看数据。我想使用Datagrip,但是我无法弄清楚如何将其连接到DB。
-Djava.security.krb5.realm=realm -Djava.security.krb5.kdc=kdc
,但不能理解如何获取境界
和kdc
的正确值
I have Postgres DB that uses kerberos authentication. So I configured my /etc/krb5.conf
file, run kinit
and now can use it, for example in python code:
import psycopg2
conn = psycopg2.connect(
host="database.address.com",
database="tested",
user="username",
port=5472
)
# Get version
cursor = conn.cursor()
cursor.execute('SELECT VERSION()')
row = cursor.fetchone()
print(row)
It works perfectly, but sometime it is very useful to have ability to watch data in tables. I want to use DataGrip, but I can't figured out how to connect it to DB.
I found some old question about it: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000757404-DataGrip-Mac-Kerberos-Authentication-with-PostgreSQL
-Djava.security.krb5.realm=realm -Djava.security.krb5.kdc=kdc
but can't understand how to get correct values for realm
and kdc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
打开数据源属性,转到高级选项卡并将其添加到VM选项字段中:
-djava.security.auth.login.config =< path; path_to>/jaas.conf
如果无济
如果仍然不起作用,请向您的DBA询问
kdc
和realm
names。Open up data source properties, go to Advanced tab and add this to VM options field:
-Djava.security.auth.login.config=<path_to>/jaas.conf
If it does not help and you have working krb5.conf also add this
-Djava.security.krb5.conf=/etc/krb5.conf
to the VM optionsIf it still does not work, please ask your DBA for
kdc
andrealm
names.