Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis use a username for authentication?

Tags:

database

redis

I have set up Redis in my environment, and have only seen a section for authorizing via a password. Is there a way to set up a username too? Or is it only authenticated via password?

like image 230
Mike Avatar asked Sep 09 '25 18:09

Mike


2 Answers

On Redis 6 there are ACL's. These have a username. Check out https://redis.io/topics/acl

To get access with a username add the following on the redis.conf file:

user bert allcommands allkeys on >abc123
requirepass foobar

The 'user' command adds the user, and the requirepass command just sets the password for user 'default'.

To show how this looks in the redis-cli:

Redis# redis-cli -a foobar
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> ACL LIST
1) "user bert on #6ca13d52ca70c883e0f0bb101e425a89e8624de51db2d2392593af6a84118090 ~* &* +@all"
2) "user default on #c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2 ~* &* +@all"

And login in, from redis-cli, on user 'bert':

redis-cli --user bert --pass abc123

It is currently unclear from the documentation how you can do this out of a program like NodeJS.

like image 153
BertC Avatar answered Sep 13 '25 04:09

BertC


If you came here default username for redis, it is default.

If you have started Redis via docker like this redis-server --requirepass secretPassword! --protected-mode yes, then the redis URL in Python celery etc should be redis://default:secretPassword!@localhost/0.

like image 32
JTX Avatar answered Sep 13 '25 05:09

JTX