Home > php教程 > php手册 > body text

redis访问权限控制,密码设置

WBOY
Release: 2016-06-13 10:09:23
Original
1492 people have browsed it

本文章来给大家介绍关于redis访问权限控制,密码设置基本步骤,有需要了解的朋友不防进入参考。

redis作为一个高速数据库,在互联网上,必须有对应的安全机制来进行保护。

1.比较安全的办法是采用绑定IP的方式来进行控制。

 代码如下 复制代码

bind 127.0.0.1

表示仅仅允许通过127.0.0.1这个ip地址进行访问。那么其实只有自己才能访问自己了,其他机器都无法访问他。

这段命令要去redis.conf里修改。

这里请注意

我们常用的启动方式src/redis-server

改为

 代码如下 复制代码
src/redis-server redis.conf

因为它需要加载配置文件。

这个方法有一点不太好,我难免有多台机器访问一个redis服务

2.设置密码,以提供远程登陆

 代码如下 复制代码
redis.conf
找到
requirepass

写上

requirepass yourpassword设置密码以后发现可以登陆,但是无法执行命令了。

 代码如下 复制代码
src/redis-cli -h 192.168.1.121
keys *
(error) ERR operation not permitted

授权命令
auth 123456登陆带密码方式

./redis-cli -h 192.168.1.121 -a hzhutid由于redis并发能力极强,仅仅搞密码,攻击者可能在短期内发送大量猜密码的请求,很容易暴力破解,所以建议密码越长越好,比如20位。(密码在 conf文件里是明文,所以不用担心自己会忘记)

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!