1
0

users-command.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. [float]
  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. [float]
  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. https://en.wikipedia.org/wiki/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 {xpack-ref}/file-realm.html[File-based User Authentication].
  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. [float]
  34. === Parameters
  35. `-a <roles>`:: If used with the `roles` parameter, adds a comma-separated list
  36. of roles to a user.
  37. //`-h, --help`:: Returns all of the command parameters.
  38. `list`:: List the users that are registered with the `file` realm
  39. on the local node. If you also specify a user name, the command provides
  40. information for that user.
  41. `-p <password>`:: Specifies the user's password. If you do not specify this
  42. parameter, the command prompts you for the password.
  43. +
  44. --
  45. TIP: Omit the `-p` option to keep
  46. plaintext passwords out of the terminal session's command history.
  47. --
  48. `passwd <username>`:: Resets a user's password. You can specify the new
  49. password directly with the `-p` parameter.
  50. `-r <roles>`::
  51. * If used with the `useradd` parameter, defines a user's roles. This option
  52. accepts a comma-separated list of role names to assign to the user.
  53. * If used with the `roles` parameter, removes a comma-separated list of roles
  54. from a user.
  55. `roles`:: Manages the roles of a particular user. You can combine adding and
  56. removing roles within the same command to change a user's roles.
  57. //`-s, --silent`:: Shows minimal output.
  58. `useradd <username>`:: Adds a user to your local node.
  59. `userdel <username>`:: Deletes a user from your local node.
  60. //`-v, --verbose`:: Shows verbose output.
  61. //[float]
  62. //=== Authorization
  63. [float]
  64. === Examples
  65. The following example adds a new user named `jacknich` to the `file` realm. The
  66. password for this user is `theshining`, and this user is associated with the
  67. `network` and `monitoring` roles.
  68. [source,shell]
  69. -------------------------------------------------------------------
  70. bin/elasticsearch-users useradd jacknich -p theshining -r network,monitoring
  71. -------------------------------------------------------------------
  72. The following example lists the users that are registered with the `file` realm
  73. on the local node:
  74. [source, shell]
  75. ----------------------------------
  76. bin/elasticsearch-users list
  77. rdeniro : admin
  78. alpacino : power_user
  79. jacknich : monitoring,network
  80. ----------------------------------
  81. Users are in the left-hand column and their corresponding roles are listed in
  82. the right-hand column.
  83. The following example resets the `jacknich` user's password:
  84. [source,shell]
  85. --------------------------------------------------
  86. bin/elasticsearch-users passwd jachnich
  87. --------------------------------------------------
  88. Since the `-p` parameter was omitted, the command prompts you to enter and
  89. confirm a password in interactive mode.
  90. The following example removes the `network` and `monitoring` roles from the
  91. `jacknich` user and adds the `user` role:
  92. [source,shell]
  93. ------------------------------------------------------------
  94. bin/elasticsearch-users roles jacknich -r network,monitoring -a user
  95. ------------------------------------------------------------
  96. The following example deletes the `jacknich` user:
  97. [source,shell]
  98. --------------------------------------------------
  99. bin/elasticsearch-users userdel jacknich
  100. --------------------------------------------------