users-command.asciidoc 4.5 KB

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