Tying to setup username and password for redis (6). Have seen some documentation that helps setting up a password for redis. Is there a way I can set both the username and password?
Asked
Active
Viewed 1,988 times
2
-
Take a look at [Redis ACL](https://redis.io/docs/manual/security/acl/) – for_stack Sep 19 '22 at 01:23
1 Answers
1
For Redis 6 and above, the recommended way to create users is to use the Redis Access Control List (ACL).
You create (and modify) a user with the acl setuser
command together with a number of rules that you want to apply to the user. A rule is either a command rule or a user management rule.
Read more about the rules you can apply to a user here.
Example: acl setuser redis_user >redis_password on allchannels allkeys +get +set +del
redis_user
: The username.>redis_password
: Adds passwordredis_password
to user. A user can have more then one password.on
: User is enabled. Useoff
to disable a user.allchannels
: Allows the user to access all pub/sub channels.allkeys
: Allows the user to access all the keys.+get +set +del
: Allows the user to use the commands in the list. A-
before the command removes the permission. Besides commands (+
/-
) you can also use categories (+@
/-@
) which are groups of commands. Use commandacl cat
to list all categories andacl cat <CATEGORY>
to list all commands for a specific category.
If you try to run a command that is not permitted you'll get the following error: (error) NOPERM User redis_user has no permissions to run the 'mset' command
.
Use redis-cli --user redis_user --pass redis_password
to log in with the new user.

duckoak
- 40
- 5