--- slug: /en/operations/settings/settings-users sidebar_position: 63 sidebar_label: User Settings --- # Users and Roles Settings The `users` section of the `user.xml` configuration file contains user settings. :::note ClickHouse also supports [SQL-driven workflow](../../guides/sre/user-management/index.md#access-control) for managing users. We recommend using it. ::: Structure of the `users` section: ``` xml ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBNxeV2uN5UY6CUbCzTA1rXfYimKQA5ivNIqxdax4bcMXz4D0nSk2l5E1TkR5mG8EBWtmExSPbcEPJ8V7lyWWbA8= ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCpgqL1SHhPVBOTFlOm0pu+cYBbADzC2jL41sPMawYCJHDyHuq7t+htaVVh2fRgpAPmSEnLEC2d4BEIKMtPK3bfR8plJqVXlLt6Q8t4b1oUlnjb3VPA9P6iGcW7CV1FBkZQEVx8ckOfJ3F+kI5VsrRlEDgiecm/C1VPl0/9M2llW/mPUMaD65cM9nlZgM/hUeBrfxOEqM11gDYxEZm1aRSbZoY4dfdm3vzvpSQ6lrCrkjn3X2aSmaCLcOWJhfBWMovNDB8uiPuw54g3ioZ++qEQMlfxVsqXDGYhXCrsArOVuW/5RbReO79BvXqdssiYShfwo+GhQ0+aLWMIW/jgBkkqx/n7uKLzCMX7b2F+aebRYFh+/QXEj7SnihdVfr9ud6NN3MWzZ1ltfIczlEcFLrLJ1Yq57wW6wXtviWh59WvTWFiPejGjeSjjJyqqB49tKdFVFuBnIU5u/bch2DXVgiAEdQwUrIp1ACoYPq22HFFAYUJrL32y7RxX3PGzuAv3LOc= 0|1 profile_name default default expression GRANT SELECT ON system.* ``` ### user_name/password {#user-namepassword} Password can be specified in plaintext or in SHA256 (hex format). - To assign a password in plaintext (**not recommended**), place it in a `password` element. For example, `qwerty`. The password can be left blank. - To assign a password using its SHA256 hash, place it in a `password_sha256_hex` element. For example, `65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5`. Example of how to generate a password from shell: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-' The first line of the result is the password. The second line is the corresponding SHA256 hash. - For compatibility with MySQL clients, password can be specified in double SHA1 hash. Place it in `password_double_sha1_hex` element. For example, `08b4a0f1de6ad37da17359e592c8d74788a83eb0`. Example of how to generate a password from shell: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha1sum | tr -d '-' | xxd -r -p | sha1sum | tr -d '-' The first line of the result is the password. The second line is the corresponding double SHA1 hash. ### username/ssh-key {#user-sshkey} This setting allows authenticating with SSH keys. Given a SSH key (as generated by `ssh-keygen`) like ``` ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj john@example.com ``` The `ssh_key` element is expected to be ``` ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDNf0r6vRl24Ix3tv2IgPmNPO2ATa2krvt80DdcTatLj ``` Substitute `ssh-ed25519` with `ssh-rsa` or `ecdsa-sha2-nistp256` for the other supported algorithms. ### access_management {#access_management-user-setting} This setting enables or disables using of SQL-driven [access control and account management](../../guides/sre/user-management/index.md#access-control) for the user. Possible values: - 0 — Disabled. - 1 — Enabled. Default value: 0. ### grants {#grants-user-setting} This setting allows to grant any rights to selected user. Each element of the list should be `GRANT` query without any grantees specified. Example: ```xml GRANT SHOW ON *.* GRANT CREATE ON *.* WITH GRANT OPTION GRANT SELECT ON system.* ``` This setting can't be specified at the same time with `dictionaries`, `access_management`, `named_collection_control`, `show_named_collections_secrets` and `allow_databases` settings. ### user_name/networks {#user-namenetworks} List of networks from which the user can connect to the ClickHouse server. Each element of the list can have one of the following forms: - `` — IP address or network mask. Examples: `213.180.204.3`, `10.0.0.1/8`, `10.0.0.1/255.255.255.0`, `2a02:6b8::3`, `2a02:6b8::3/64`, `2a02:6b8::3/ffff:ffff:ffff:ffff::`. - `` — Hostname. Example: `example01.host.ru`. To check access, a DNS query is performed, and all returned IP addresses are compared to the peer address. - `` — Regular expression for hostnames. Example, `^example\d\d-\d\d-\d\.host\.ru$` To check access, a [DNS PTR query](https://en.wikipedia.org/wiki/Reverse_DNS_lookup) is performed for the peer address and then the specified regexp is applied. Then, another DNS query is performed for the results of the PTR query and all the received addresses are compared to the peer address. We strongly recommend that regexp ends with $. All results of DNS requests are cached until the server restarts. **Examples** To open access for user from any network, specify: ``` xml ::/0 ``` :::note It’s insecure to open access from any network unless you have a firewall properly configured or the server is not directly connected to Internet. ::: To open access only from localhost, specify: ``` xml ::1 127.0.0.1 ``` ### user_name/profile {#user-nameprofile} You can assign a settings profile for the user. Settings profiles are configured in a separate section of the `users.xml` file. For more information, see [Profiles of Settings](../../operations/settings/settings-profiles.md). ### user_name/quota {#user-namequota} Quotas allow you to track or limit resource usage over a period of time. Quotas are configured in the `quotas` section of the `users.xml` configuration file. You can assign a quotas set for the user. For a detailed description of quotas configuration, see [Quotas](../../operations/quotas.md#quotas). ### user_name/databases {#user-namedatabases} In this section, you can limit rows that are returned by ClickHouse for `SELECT` queries made by the current user, thus implementing basic row-level security. **Example** The following configuration forces that user `user1` can only see the rows of `table1` as the result of `SELECT` queries, where the value of the `id` field is 1000. ``` xml id = 1000 ``` The `filter` can be any expression resulting in a [UInt8](../../sql-reference/data-types/int-uint.md)-type value. It usually contains comparisons and logical operators. Rows from `database_name.table1` where filter results to 0 are not returned for this user. The filtering is incompatible with `PREWHERE` operations and disables `WHERE→PREWHERE` optimization. ## Roles You can create any predefined roles using the `roles` section of the `user.xml` configuration file. Structure of the `roles` section: ```xml GRANT SHOW ON *.* REVOKE SHOW ON system.* GRANT CREATE ON *.* WITH GRANT OPTION ``` These roles can also be granted to users from the `users` section: ```xml ... GRANT test_role ```