web123456

Configuring passwords for redis in linux

catalogs

  • preamble
  • 1. Temporary passwords
  • 2. Permanent password
  • 3. Validation

preamble

If the server is built with theredis
If you don't set a password, it can be compromised causing your cpu to spike instantly
Then it's best to set a password.

1. Temporary passwords

Since I configured the login mode for the backend
So it starts right up in the background.
(Setting the daemonize value to yes allows you to log in via the backend)redis-server /etc/

Afterwards, get the file'srequirepassThe value of the query is the value of the query.
Given a password, which is a value

root@gaokaoli:/opt/redis-6.2.1# redis-server /etc/redis.conf
root@gaokaoli:/opt/redis-6.2.1# redis-cli
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass 123456
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"
127.0.0.1:6379> 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

The screenshots are as follows

在这里插入图片描述

2. Permanent password

Find this setting in the configuration filerequirepass foobared

在这里插入图片描述
Fill in your password at the back.

Before you do this, restart your redis service, every time you change the configuration file, you have to restart your service to be successful

After that, you need a password to log in.

在这里插入图片描述
(I don't know why, but the permanent password doesn't seem to work, I don't know if it's a version problem or if it's because I've changed the settings and the permanent password doesn't work)

在这里插入图片描述
If anyone knows anything, let me know in the comments section!

3. Validation

By entering the following screen

root@gaokaoli:/opt# redis-cli
127.0.0.1:6379> config get requirepass
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

The screenshots are as follows
在这里插入图片描述