Introduction

Redis is a popular in-memory database known for its speed and versatility. By default, Redis allows only local connections, we can enable secure remote access for specific use cases

Prerequisite

  1. A user with sudo privilege access to SSH the server

Implementation

Step 1: Install Redis

$ sudo apt update

$ sudo apt install redis-server -y

Step 2: Start and enable the Redis service

$ sudo systemctl start redis
$ sudo systemctl enable redis

Step 3: Edit the Redis configuration to allow the remote access

$ vi /etc/redis/redis.conf

Search for the keyword “bind” and update the IP as mentioned

bind 0.0.0.0

Step 4: Setup the secure password

Search with the keyword “requirepass” on the same configuration file and update the strong password then save & exit the file

requirepass YourSecurePasswordHere

Step 5: Restart the Redis service

$ sudo systemctl restart redis

Step 6: Configure Firewall Rules to restrict access and allow only the specific remote server’s IP

$ sudo ufw enable

$ sudo ufw allow from <IP> to any port 6379

Note: Redis default port is 6379

Step 7: Reload UFW Rules

$ sudo ufw reload

Leave a Reply