RabbitMQ: List | Create Users – Rabbitmqctl

The internal RabbitMQ users can be managed from the command-line using the rabbitmqctl command.

Note, that the users from any alternative authentication backends (e.g. LDAP) cannot be inspected or managed with the commands listed below.

In this note i will show how to list, create, set permissions and delete internal RabbitMQ users from the command-line using the rabbitmqctl command.

Cool Tip: How to list, create & delete vHosts in RabbitMQ! Read more →

RabbitMQ Users – List, Create, Set Tags/Permissions

List all users:

$ rabbitmqctl list_users

Create a user and set a password:

$ rabbitmqctl add_user <userName> <password>

Give admin privileges to a user:

$ rabbitmqctl set_user_tags <userName> administrator

Set permissions for a user:

$ rabbitmqctl set_permissions -p <vhostName> <userName> <conf> <write> <read>

For example, this command instructs the RabbitMQ broker to grant the user named “janeway” access to the virtual host called “my-vhost”, with configure permissions on all resources whose names starts with “janeway-“, and write and read permissions on all resources (source):

$ rabbitmqctl set_permissions -p my-vhost janeway "^janeway-.*" ".*" ".*"

RabbitMQ Users – Delete

Remove any tags from a user:

$ rabbitmqctl set_user_tags <userName>

Deny a user to access a virtual host:

$ rabbitmqctl clear_permissions -p <vhostName> <userName>

Delete a user:

$ rabbitmqctl delete_user <userName>