84

This seems like a question that should be easily be googleable. It is not though. Can anybody help?

How do I create a new user for rabbitmq?

Tobias Gassmann
  • 11,399
  • 15
  • 58
  • 92

5 Answers5

143

I have found this very useful

This adds a new user and password

rabbitmqctl add_user username password

This makes the user a administrator

rabbitmqctl set_user_tags username administrator

This sets permissions for the user

rabbitmqctl set_permissions -p / username ".*" ".*" ".*"

See more here https://www.rabbitmq.com/rabbitmqctl.8.html#User_Management

Community
  • 1
  • 1
John Kitonyo
  • 2,109
  • 1
  • 14
  • 17
104

You can use the rabbitmqctl tool - look for subtitle User management. The command to create a user is:

$ rabbitmqctl add_user myUser myPass

To make user an administrator run:

$ rabbitmqctl set_user_tags myUser administrator

Also if you use rabbitmq web UI - the management plugin you can do it quite easily, it's pretty intuitive.

If you want to do it programmatically you can also use rabbitmq rest API, also explained in (on?) the link for management plugin.

cantSleepNow
  • 9,691
  • 5
  • 31
  • 42
  • 1
    if someone could please explain the downvote, I'd be happy to improve this, other and all my future answers. – cantSleepNow Mar 15 '19 at 18:27
  • 1
    FYI some of these links are dead. If you or a mod could update them that would be helpful – Matthew Scouten Sep 27 '21 at 23:37
  • 1
    first link was dead, updated now – cantSleepNow Sep 28 '21 at 10:49
  • Can you please elaborate on this cantSleepNow? What boggles my mind is that the official docs https://www.rabbitmq.com/access-control.html say absolutely nothing about an administrator user. What I'm trying to figure out is why do I need to set a tag (administrator) if apparently I need to set permissions on vhost anyway? (at least that's what the other people suggest in this thread) so what is the purpose of the tag? The thing is I have a User on my RabbitMQ installation that has the tag administrator but he has no rights to maintain certain vHosts. That confuses the hell out of me. – lema Feb 18 '23 at 18:56
  • seems based on https://stackoverflow.com/a/52295727/11971304 the tag is just for viewing purpose and doesn't actually do anything on its own. so when the tagged user is provided with admin rights by setting permissions, then it gives a pseudo feeling of a admin user (visibly) – mahee96 May 01 '23 at 17:33
  • @mahee96 So something that happened before another thing is based on it? Look at the timestamps of the both answers. I did edit it later for formatting purpose I think, but still... – cantSleepNow May 02 '23 at 06:13
24

you want to add new user for RabbitMQ server just run below comments cmd :

  1. rabbitmqctl add_user test test
  2. rabbitmqctl set_user_tags test administrator
  3. rabbitmqctl set_permissions -p / test ".*" ".*" ".*"
Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96
Bharathiraja
  • 241
  • 2
  • 2
12

To enable RabbitMQ admin management user please follow :

  • rabbitmqctl add_user daniel daniel
  • rabbitmqctl set_user_tags daniel administrator
  • rabbitmqctl set_permissions -p / daniel ".*" ".*" ".*"
  • List item

Now access your RabbitMQ admin on the your host as :

http://{youhostname}:15672/#/

and, log in with your above user account!

Greg Sadetsky
  • 4,863
  • 1
  • 38
  • 48
Develop4Life
  • 7,581
  • 8
  • 58
  • 76
2

Once the management plugin has been enabled you can also use the REST API.

PUT /api/users/name
Jeremy Hamm
  • 499
  • 1
  • 5
  • 14