Last active
February 2, 2020 20:00
-
-
Save rakibulinux/e88bbbf22a28bf044f722b07b406ad2b to your computer and use it in GitHub Desktop.
How To Install and Secure Redis on Ubuntu 18.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!bin/sh | |
sudo apt update | |
sudo apt install redis-server | |
#Open this file with your preferred text editor. Inside the file, find the supervised directive. This directive allows you to declare an init system to manage Redis as a service, providing you with more control over its operation. The supervised directive is set to no by default. Since you are running Ubuntu, which uses the systemd init system, change this to (systemd): | |
sudo nano /etc/redis/redis.conf | |
Add this (supervised systemd) | |
sudo systemctl restart redis.service | |
sudo systemctl status redis | |
#Extra desirable Settings | |
sudo systemctl disable redis | |
redis-cli | |
ping | |
Output | |
PONG | |
set test "It's working!" | |
Output | |
OK | |
get test | |
"It's working!" | |
exit | |
#Securing Redis Installation | |
sudo nano /etc/redis/redis.conf | |
#On the 'bind' section, change the IP address with your own internal network IP address. | |
bind INTERNAL-IP-ADDRESS (127.0.0.1) | |
#Password Authentication. Uncomment the 'requirepass' section | |
requirepass G@kfse-labs321@#$ | |
#Disabling Dangerous Redis Command | |
# rename-command COMMAND "CUSTOM" | |
rename-command FLUSHALL "DELITALL" | |
rename-command CONFIG "MYSERVERCONF" | |
systemctl restart redis-server | |
#Testing Host and Authentication | |
redis-cli -h 127.0.0.1 -p 6379 | |
#This command will not work it will show "(error) NOAUTH Authentication required." | |
ping | |
ping "Hello Redis" | |
#Now Run the following command to authenticate against the Redis Server. I use my AUTH key you should use your own. | |
AUTH G@kfse-labs321@#$ | |
#Now Check with this command | |
ping | |
ping "Hello Redis" | |
#Run all commands that we've renamed on the shell and you will get the command error. | |
FLUSHALL | |
CONFIG | |
#Next, run the 'CUSTOM' commands for each. Create new Key using through redis-cli command as below. | |
SET Name "Rakib Linux" | |
SET Blog "rakibulinux.github.io" | |
Keys * | |
#Now delete all keys and data using the renamed 'FLUSHALL' command 'Rakibulinux'. I change with "Rakibulinux". So, i use thsi. | |
Rakibulinux | |
Rakibulinux get bind | |
Rakibulinux2 get requirepass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment