04-postgresql-9.6.1安全管理之pg_hba.conf配置(2017-06-12)
来源:互联网 发布:广角镜头拍摄效果知乎 编辑:程序博客网 时间:2024/06/05 04:28
- 1测试需求
- 2步骤
- 1检查192168181141上的postgresql数据库的postgres用户l密码
- 2修改密码为postgres
- 3配置192168181141的pg_hbaconf文件
- 4测试
- 5附加测试配置pgpass
1、测试需求
192.168.181.141上的postgresql数据库,192.168.1.138要无密码登录进来,192.168.181.181要md5登录
2、步骤
1)检查192.168.181.141上的postgresql数据库的postgres用户l密码
postgres=# select pg_user.usename,pg_user.passwd from pg_user; usename | passwd ----------+---------- postgres | ********(1 row)postgres=# select usename,passwd from pg_shadow; usename | passwd----------+-------- postgres |(1 row)postgres=# select md5(''); md5 ---------------------------------- d41d8cd98f00b204e9800998ecf8427e(1 row)postgres=# select rolname,rolpassword from pg_authid; rolname | rolpassword-------------------+------------- postgres | pg_signal_backend |(2 rows)postgres=# select rolname,rolpassword from pg_authid; rolname | rolpassword-------------------+------------- postgres | pg_signal_backend |(2 rows)
2)修改密码为postgres
postgres=# ALTER USER postgres WITH PASSWORD 'postgres';ALTER ROLE
3)配置192.168.181.141的pg_hba.conf文件。
host all all 192.168.181.180/32 md5host all all 192.168.181.138/32 trust
备注:例如如下的配置,会按顺序从上往下执行。
# "local" is for Unix domain socket connections onlylocal all all trust# IPv4 local connections:host all all 127.0.0.1/32 trusthost replication postgres 192.168.1.145/32 trusthost replication postgres 192.168.1.146/32 trusthost all postgres 192.168.1.0/32 md5host all all 0.0.0.0/0 md5
0.0.0.0/32表示 允许地址在0.0.0.0-255.255.255.255范围内的客户端
192.168.1.0/24表示子网掩码为255.255.255.0,此时允许192.168.1.0-192.168.1.255范围内的客户端地址链接。
192.168.1.0/32表示IP为192.168.1.0
4)测试
pg961为192.168.181.180
[postgres@pg961 opt]$ psql -h 192.168.181.141 -p 5432 -U postgresPassword for user postgres:psql (9.6.1)Type "help" for help.postgres=#
zabbix为192.168.181.138
[postgres@zabbix /]$psql -h 192.168.181.141 -p 5432psql (9.5.4, 服务器 9.6.1)警告:psql 主版本9.5,服务器主版本为9.6. 一些psql功能可能无法正常使用。输入 "help" 来获取帮助信息.postgres=
5)附加测试:配置.pgpass
因为从192.168.181.180登录到192.168.181.141的数据库中,每次要输入密码。那么可以在/home/postgre/目录下建立一个文件
格式:hostname:port:database:username:password
[postgres@pg961 opt]$ vim /home/postgres/.pgpass192.168.181.141:5432:postgres:postgres:postgres
再次进行登录就可以不用密码了。
[postgres@pg961 opt]$ psql -h 192.168.181.141 -p 5432 -U postgrespsql (9.6.1)Type "help" for help.postgres=#
测试完成
阅读全文
0 0
- 04-postgresql-9.6.1安全管理之pg_hba.conf配置(2017-06-12)
- postgresql pg_hba.conf 文件
- Postgresql pg_hba.conf配置文件小结
- 修改PostgreSQL中pg_hba.conf
- PostgreSQL pg_hba.conf 文件简析
- PostgreSQL的 pg_hba.conf 文件简析
- PostgreSQL远程数据库连接 && PostgreSQL pg_hba.conf 文件简析
- pg_hba.conf
- PostgreSQL 连接问题 FATAL: no pg_hba.conf entry for host
- 程序链接PostgreSQL 时报错"no pg_hba.conf entry"
- PostgreSQL pg_hba.conf 文件简析(转)
- PostgreSQL 连接问题 FATAL: no pg_hba.conf entry for host
- postgresql.conf配置
- postgresql.conf配置解析
- Unable to connect to PostgreSQL server: FATAL: missing or erroneous pg_hba.conf file\nHINT: See se
- PostgreSQL启动过程中的那些事十五.一:pg_hba.conf的用法
- PostgreSQL pg_hba.conf 文件解析以及忘记密码的处理方法
- postgreSQL远程连接出现:Error connecting to server :致命错误 SSL关闭的pg_hba.conf记录
- ionic+angularjs,返回并刷新页面。
- TensorFlow实现卷积神经网络
- Okhttp使用和源码分析一(OkHttp2.x用法)
- 西门子S7-200 smart Microwin smart V2.2 安装问题处理流程
- [BZOJ 3524][Poi2014]Couriers:可持久化线段树
- 04-postgresql-9.6.1安全管理之pg_hba.conf配置(2017-06-12)
- C语言.求最大公约数最小公倍数
- DLL 即动态链接库
- 自定义下拉框
- Tinker热修复简单使用与接入
- ssm+redis+solr小例子
- 1006. Sign In and Sign Out (25)
- 数据库没连上,远程数据库的网络不通
- 有关语音方面的深度学习资料合集