Redis Security

We can set a password parameter through the redis configuration file, so that clients connecting to the redis service require password verification, which can make your redis service more secure.

Example

We can check whether password verification is set with the following command:

127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) ""

By default, the requirepass parameter is empty, which means you can connect to the redis service without password verification.

You can modify this parameter with the following command:

127.0.0.1:6379> CONFIG set requirepass "example"
OK
127.0.0.1:6379> CONFIG get requirepass
1) "requirepass"
2) "example"

After setting the password, clients connecting to the redis service need password verification; otherwise, commands cannot be executed.

Syntax

AUTHThe basic syntax format of the command is as follows:

127.0.0.1:6379> AUTH password

Example

127.0.0.1:6379> AUTH "example"
OK
127.0.0.1:6379> SET mykey "Test value"
OK
127.0.0.1:6379> GET mykey
"Test value"
Other Extensions