users-command.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. [[users-command]]
  2. == elasticsearch-users
  3. If you use file-based user authentication, the `elasticsearch-users` command
  4. enables you to add and remove users, assign user roles, and manage passwords.
  5. [discrete]
  6. === Synopsis
  7. [source,shell]
  8. --------------------------------------------------
  9. bin/elasticsearch-users
  10. ([useradd <username>] [-p <password>] [-r <roles>]) |
  11. ([list] <username>) |
  12. ([passwd <username>] [-p <password>]) |
  13. ([roles <username>] [-a <roles>] [-r <roles>]) |
  14. ([userdel <username>])
  15. --------------------------------------------------
  16. [discrete]
  17. === Description
  18. If you use the built-in `file` internal realm, users are defined in local files
  19. on each node in the cluster.
  20. Usernames and roles must be at least 1 and no more than 1024 characters. They
  21. can contain alphanumeric characters (`a-z`, `A-Z`, `0-9`), spaces, punctuation,
  22. and printable symbols in the
  23. {wikipedia}/Basic_Latin_(Unicode_block)[Basic Latin (ASCII) block].
  24. Leading or trailing whitespace is not allowed.
  25. Passwords must be at least 6 characters long.
  26. For more information, see <<file-realm>>.
  27. TIP: To ensure that {es} can read the user and role information at startup, run
  28. `elasticsearch-users useradd` as the same user you use to run {es}. Running the
  29. command as root or some other user updates the permissions for the `users` and
  30. `users_roles` files and prevents {es} from accessing them.
  31. [discrete]
  32. [[users-command-parameters]]
  33. === Parameters
  34. `-a <roles>`:: If used with the `roles` parameter, adds a comma-separated list
  35. of roles to a user.
  36. //`-h, --help`:: Returns all of the command parameters.
  37. `list`:: List the users that are registered with the `file` realm
  38. on the local node. If you also specify a user name, the command provides
  39. information for that user.
  40. `-p <password>`:: Specifies the user's password. If you do not specify this
  41. parameter, the command prompts you for the password.
  42. +
  43. --
  44. TIP: Omit the `-p` option to keep
  45. plaintext passwords out of the terminal session's command history.
  46. --
  47. `passwd <username>`:: Resets a user's password. You can specify the new
  48. password directly with the `-p` parameter.
  49. `-r <roles>`::
  50. * If used with the `useradd` parameter, defines a user's roles. This option
  51. accepts a comma-separated list of role names to assign to the user.
  52. * If used with the `roles` parameter, removes a comma-separated list of roles
  53. from a user.
  54. `roles`:: Manages the roles of a particular user. You can combine adding and
  55. removing roles within the same command to change a user's roles.
  56. //`-s, --silent`:: Shows minimal output.
  57. `useradd <username>`:: Adds a user to your local node.
  58. `userdel <username>`:: Deletes a user from your local node.
  59. //`-v, --verbose`:: Shows verbose output.
  60. //[discrete]
  61. //=== Authorization
  62. [discrete]
  63. === Examples
  64. The following example adds a new user named `jacknich` to the `file` realm. The
  65. password for this user is `theshining`, and this user is associated with the
  66. `network` and `monitoring` roles.
  67. [source,shell]
  68. -------------------------------------------------------------------
  69. bin/elasticsearch-users useradd jacknich -p theshining -r network,monitoring
  70. -------------------------------------------------------------------
  71. The following example lists the users that are registered with the `file` realm
  72. on the local node:
  73. [source, shell]
  74. ----------------------------------
  75. bin/elasticsearch-users list
  76. rdeniro : admin
  77. alpacino : power_user
  78. jacknich : monitoring,network
  79. ----------------------------------
  80. Users are in the left-hand column and their corresponding roles are listed in
  81. the right-hand column.
  82. The following example resets the `jacknich` user's password:
  83. [source,shell]
  84. --------------------------------------------------
  85. bin/elasticsearch-users passwd jachnich
  86. --------------------------------------------------
  87. Since the `-p` parameter was omitted, the command prompts you to enter and
  88. confirm a password in interactive mode.
  89. The following example removes the `network` and `monitoring` roles from the
  90. `jacknich` user and adds the `user` role:
  91. [source,shell]
  92. ------------------------------------------------------------
  93. bin/elasticsearch-users roles jacknich -r network,monitoring -a user
  94. ------------------------------------------------------------
  95. The following example deletes the `jacknich` user:
  96. [source,shell]
  97. --------------------------------------------------
  98. bin/elasticsearch-users userdel jacknich
  99. --------------------------------------------------