This article will discuss one of Redis’s security features called protected mode.
What Is Redis Protected Mode?
Redis protected mode is a security feature that prevents the Redis server from responding to queries outside the loopback interfaces.
The Redis server will return an error to any client connecting outside loopback addresses in protected mode.
Redis will automatically start in protected mode if the instance is bound to all interfaces, and no password has been set to access it.
Although it is not recommended, you can disable protected mode and start the Redis server without a password.
Redis Check Protected Mode
It is good to check if the Redis server is operating in protected mode. You can do this using the config command.
Start by connecting to the Redis CLI as shown below:
Next, run the command as provided below:
Redis should return the output as shown below:
1) “protected-mode”
2) “no”
In this case, the protected mode is disabled.
To change the status of Redis protected mode, run the following command:
Change the value of protected mode to your desired value. Once the configuration is set, restart the Redis server to apply the changes.
You can add the following line to the Redis configuration file to manage protected mode:
Securing Redis With a Password
Enabling the protected mode without setting a password is as good as doing nothing. To implement protected mode with a password, you need to set a password for your Redis cluster.
Open the Redis configuration file.
Navigate to the SECURITY section of the file and add the following entry:
Remember to set a secure password for your cluster.
NOTE: In some cases, the entry may exist but be commented out.
Save and close the configuration file. Finally, restart the Redis server:
Conclusion
This guide discusses the Redis protected mode, checking if the protected mode is enabled in Redis, and securing Redis with a password. We hope you found this article helpful. Check the other Linux Hint articles for more tips and information.