Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis login

2025-04-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Redis login

The default configuration of Redis does not require password authentication, which means that as long as the host and port of the connected Redis server are correct, you can connect and use it. There will be some problems in security, so it is necessary to enable the authentication password of Redis to increase the security of the Redis server.

Modify the configuration file redis.conf

# requirepass foobared

Remove the previous comment and change it to the required password:

Requirepass 147258 (where 147258 is the password to be set)

After setting the Redis authentication password, the client needs to enter the authentication password using the-a parameter when logging in. Although you can log in successfully without adding this parameter, you do not have any operation permission.

# login without a specified password

[root@Darren1 redis] # redis-cli-h 192.168.91.23-p 6379

192.168.91.23 6379 > ping

(error) NOAUTH Authentication required.

192.168.91.23 6379 > keys *

(error) NOAUTH Authentication required.

# Log in with password authentication (where-p is lowercase)

[root@Darren1 redis] # redis-cli-h 192.168.91.23-p 6379-a 147258

192.168.91.23 6379 > ping

PONG

# in addition to using the-a parameter to enter the login password when logging in as above, you can also use auto to verify after the connection without specifying:

[root@Darren1 redis] # redis-cli-h 127.0.0.1-p 6379

127.0.0.1 6379 > auth 147258

OK

127.0.0.1 purl 6379 > config get requirepass

1) "requirepass"

2) "147258"

Log in to another redis service remotely

[root@Darren1 redis] # redis-cli-h 192.168.91.22-p 6379-a 123456

192.168.91.22 6379 > ping

PONG

192.168.91.22 6379 > config get requirepass

1) "requirepass"

2) "123456"

Modify the password

(1) dynamically effective password modification

127.0.0.1 6379 > config set requirepass 123456

OK

127.0.0.1 purl 6379 > config get requirepass

1) "requirepass"

2) "123456"

[root@Darren1 redis] # redis-cli-h 127.0.0.1-p 6379-a 123456

127.0.0.1 purl 6379 > ping

PONG

(2) modify redis.conf

Requirepass123456

Using authentication passwords in Redis clusters

If the Redis server, a cluster is used. In addition to configuring passwords in master, you also need to configure them in slave. Find the following line in the configuration file of slave, uncomment and change the same password as master:

# masterauth master-password

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 293

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report