Redis

How to Use the Redis Protected Mode

Security is an essential factor in the modern age. Therefore, understanding how to secure your applications and data has become a requirement.

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:

$ redis-cli

Next, run the command as provided below:

127.0.0.1:6379> config get protected*

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:

127.0.0.1:6379> config set protected-mode yes/no

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:

protected-mode yes

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.

$ sudo nano /etc/redis/redis.conf

Navigate to the SECURITY section of the file and add the following entry:

requirepass <your_secure_password>

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:

$ sudo /etc/init.d/redis-server restart

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.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list