| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 | [role="xpack"][testenv="gold+"][[users-command]]== elasticsearch-usersIf you use file-based user authentication, the `elasticsearch-users` commandenables you to add and remove users, assign user roles, and manage passwords.[discrete]=== Synopsis[source,shell]--------------------------------------------------bin/elasticsearch-users([useradd <username>] [-p <password>] [-r <roles>]) |([list] <username>) |([passwd <username>] [-p <password>]) |([roles <username>] [-a <roles>] [-r <roles>]) |([userdel <username>])--------------------------------------------------[discrete]=== DescriptionIf you use the built-in `file` internal realm, users are defined in local fileson each node in the cluster.Usernames and roles must be at least 1 and no more than 1024 characters. Theycan contain alphanumeric characters (`a-z`, `A-Z`, `0-9`), spaces, punctuation,and printable symbols in thehttps://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)[Basic Latin (ASCII) block].Leading or trailing whitespace is not allowed.Passwords must be at least 6 characters long.For more information, see <<file-realm>>.TIP: To ensure that {es} can read the user and role information at startup, run`elasticsearch-users useradd` as the same user you use to run {es}. Running thecommand as root or some other user updates the permissions for the `users` and`users_roles` files and prevents {es} from accessing them.[discrete]=== Parameters`-a <roles>`:: If used with the `roles` parameter, adds a comma-separated listof roles to a user.//`-h, --help`:: Returns all of the command parameters.`list`:: List the users that are registered with the `file` realmon the local node. If you also specify a user name, the command providesinformation for that user.`-p <password>`:: Specifies the user's password. If you do not specify thisparameter, the command prompts you for the password.+--TIP: Omit the `-p` option to keepplaintext passwords out of the terminal session's command history.--`passwd <username>`:: Resets a user's password. You can specify the newpassword directly with the `-p` parameter.`-r <roles>`::* If used with the `useradd` parameter, defines a user's roles. This optionaccepts a comma-separated list of role names to assign to the user.* If used with the `roles` parameter, removes a comma-separated list of rolesfrom a user.`roles`:: Manages the roles of a particular user. You can combine adding andremoving roles within the same command to change a user's roles.//`-s, --silent`:: Shows minimal output.`useradd <username>`:: Adds a user to your local node.`userdel <username>`:: Deletes a user from your local node.//`-v, --verbose`:: Shows verbose output.//[discrete]//=== Authorization[discrete]=== ExamplesThe following example adds a new user named `jacknich` to the `file` realm. Thepassword for this user is `theshining`, and this user is associated with the`network` and `monitoring` roles.[source,shell]-------------------------------------------------------------------bin/elasticsearch-users useradd jacknich -p theshining -r network,monitoring-------------------------------------------------------------------The following example lists the users that are registered with the `file` realmon the local node:[source, shell]----------------------------------bin/elasticsearch-users listrdeniro        : adminalpacino       : power_userjacknich       : monitoring,network----------------------------------Users are in the left-hand column and their corresponding roles are listed inthe right-hand column.The following example resets the `jacknich` user's password:[source,shell]--------------------------------------------------bin/elasticsearch-users passwd jachnich--------------------------------------------------Since the `-p` parameter was omitted, the command prompts you to enter andconfirm a password in interactive mode.The following example removes the `network` and `monitoring` roles from the`jacknich` user and adds the `user` role:[source,shell]------------------------------------------------------------bin/elasticsearch-users roles jacknich -r network,monitoring -a user------------------------------------------------------------The following example deletes the `jacknich` user:[source,shell]--------------------------------------------------bin/elasticsearch-users userdel jacknich--------------------------------------------------
 |