Redis - Security

Redis database can be secured, such that any client making a connection needs to authenticate before executing a command. To secure Redis, you need to set the password in the config file.


Following example shows the steps to secure your Redis instance.> CONFIG get requirepass 
1) "requirepass" 
2) "" 

By default, this property is blank, which means no password is set for this instance. You can change this property by executing the following command.> CONFIG set requirepass "tutorialspoint" 
OK> CONFIG get requirepass 
1) "requirepass" 
2) "tutorialspoint" 

After setting the password, if any client runs the command without authentication, then (error) NOAUTH Authentication required. error will return. Hence, the client needs to use AUTH command to authenticate himself.


Following is the basic syntax of AUTH command.> AUTH password 

Example> AUTH "tutorialspoint" 
OK> SET mykey "Test value" 
OK> GET mykey 
"Test value"