RabbitMQ – Create new user

Reading Time: 2 minutes

Solution

$ rabbitmqctl add_user new_user pass
$ rabbitmqctl set_user_tags new_user administrator
$ rabbitmqctl list_users
$ rabbitmqctl set_permissions -p / new_user ".*" ".*" ".*"
$ rabbitmqctl list_permissions -p /

Explanation

$ rabbitmqctl add_user new_user pass

Create new RabbitMQ user having the username new_user and the password pass.

$ rabbitmqctl set_user_tags new_user administrator

Add administrator tag to the newly created user new_user i.e. make new_user an administrator.

$ rabbitmqctl list_users

View the list of all the users. Just to double check that the new_user has been created successfully.

$ rabbitmqctl set_permissions -p / new_user ".*" ".*" ".*"

Grant full configure, write and read permissions to the user new_user within the virtual host “/”. The generic command is $ set_permissions [-p vhost] user conf write read, where conf, write and read are regular expressions matching resources names for which the user is granted configure, write and read permissions respectively.

$ rabbitmqctl list_permissions -p /

List all the users that have been granted access to the virtual host “/” and their permissions. Just to double check we did it right in the previous steps. Note: an empty string means no permission granted.

You can find more details about the rabbitmqctl tool on this page https://www.rabbitmq.com/rabbitmqctl.8.html.

We transform challenges into digital experiences

Get in touch to let us know what you’re looking for. Our policy includes 14 days risk-free!

Free project consultation