users-command.asciidoc 4.4 KB

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