Popular blog tags

 I have two options to set a password for Redis.

 

1.using redis-cli:

root@server:~# redis-cli
redis 127.0.0.1:6379> AUTH your_redis_password
(error) ERR Client sent AUTH, but no password is set
redis 127.0.0.1:6379> CONFIG SET requirepass "mypass"
OK
redis 127.0.0.1:6379> AUTH mypass
Ok

 

remove password

root@server:~# redis-cli

redis 127.0.0.1:6379> CONFIG SET requirepass "mypass"
OK
redis 127.0.0.1:6379> AUTH mypass
Ok
redis 127.0.0.1:6379> CONFIG SET requirepass ""
OK
redis 127.0.0.1:6379> AUTH PASSWORD
(error) ERR Client sent AUTH, but no password is set

 

 

2.edit  redis.conf file

Open redis configuration file redis.conf

sudo vi /etc/redis/redis.conf

find and uncomment line # requirepass foobared, then restart server

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared

Uncomment following line and set strong password by removing default one.

Default Configuration

#requirepass foobared

Configuration after Setting Password

requirepass MyStr0ngP

now you password is MyStr0ngP

 

 

redis-cli -h example.com -p 6379 -a MyStr0ngP#d

 

Set and Connect to Redis Database with Password

https://techmonger.github.io/70/redis-password/

How To Secure Your Redis Installation on Ubuntu

https://www.digitalocean.com/community/tutorials/how-to-secure-your-redis-installation-on-ubuntu-14-04

redis: set a password for redis

https://stackoverflow.com/questions/7537905/redis-set-a-password-for-redis