2

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?

Ajai
  • 25
  • 5

1 Answers1

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 password redis_password to user. A user can have more then one password.
  • on: User is enabled. Use off 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 command acl cat to list all categories and acl 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