[Yandex Cloud documentation](../../../index.md) > [Yandex IoT Core](../../index.md) > [Step-by-step guides](../index.md) > Managing passwords > Managing broker passwords

# Managing broker passwords

{% note warning %}

Yandex IoT Core is no longer available to new users. 

Current users can create resources until November 1, 2026. Afterwards, the service will go read-only and cease to operate on December 1, 2026. For more information on the timing and procedure, see [Service shutdown](../../sunset.md).

{% endnote %}

{% note info %}

The broker is at the [Preview](../../../overview/concepts/launch-stages.md) stage.

{% endnote %}

To start exchanging messages between broker clients, you must [log in](../../concepts/authorization.md). This section describes how to manage broker passwords for the relevant authorization method.

{% note info %}

When using an X.509 certificate along with a password, the password has higher priority.

{% endnote %}

* [Adding a password](#create-or-add)
* [Viewing a password list](#list)
* [Deleting a password](#delete)

## Adding a password to a broker {#create-or-add}

You can add a password to an existing broker or set it when creating a broker using the `--password` parameter.

{% note info %}

You can also set a password from the input stream. To do this, use the `--read-password` flag instead of the `--password` parameter.

{% endnote %}

### Adding a password to an existing broker {#add}

{% list tabs group=instructions %}

- Management console {#console}

   1. In the [management console](https://console.yandex.cloud), select the folder where you want to add a password for an existing broker.
   1. Navigate to **IoT Core**.
   1. In the left-hand panel, select **Brokers**.
   1. Select the appropriate broker from the list.
   1. Under **Passwords**, click **Add password**.
   1. In the **Password** field, enter the password you will use to access the broker. To create a password, you can use [this password generator](https://passwordsgenerator.net/). Make sure to save your password, as you will need it later.
   1. Click **Add**.

- CLI {#cli}
  
    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).
    
    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

    To add a password: 
    1. Get a list of brokers in the folder: 
    
        ```
        yc iot broker list
		```
		
		Result:
		```
        +----------------------+-------------------+
        |          ID          |       NAME        |
        +----------------------+-------------------+
        | arenou2oj4********** | my-broker         |
        +----------------------+-------------------+
        ```    
    1. Add a password to the broker:
    
        ```
        yc iot broker password add --broker-name my-broker --password Passw0rdForBroker
        ```
		
		Result:
		```
		broker_id: arenou2oj4**********
        id: areuu2hgsv6k********
        created_at: "2019-12-16T15:32:46.655139Z"
        ```

- API {#api}

  To add a password to a broker, use the [addPassword](../../broker/api-ref/Broker/addPassword.md) REST API method for the [Broker](../../broker/api-ref/Broker/index.md) resource or the [BrokerService/AddPassword](../../broker/api-ref/grpc/Broker/addPassword.md) gRPC API call.

{% endlist %}

### Setting a password for a broker when creating it {#create}

{% list tabs group=instructions %}

- Management console {#console}

   For information about how to set a password for a broker when creating it, see [Creating a broker](../broker/broker-create.md).

- CLI {#cli}
  
    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).
    
    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
    
    Create a broker with a password:       
    
    ```
    yc iot broker create --name broker-with-pass --password Passw0rdForDevice
    ```
	
	Result:
	```
	done (1s)
    id: areg96c8lo**********
    folder_id: b1g88tflru**********
    created_at: "2019-12-16T15:34:25.563Z"
    name: broker-with-pass
    status: ACTIVE
    log_group_id: ckghhil3b5**********
    ```

- API {#api}

  To set a password for a broker when creating it, use the [create](../../broker/api-ref/Broker/create.md) REST API method for the [Broker](../../broker/api-ref/Broker/index.md) resource or the [BrokerService/Create](../../broker/api-ref/grpc/Broker/create.md) gRPC API call.

{% endlist %}

## Getting a list of broker passwords {#list}

{% list tabs group=instructions %}

- Management console {#console}

   1. In the [management console](https://console.yandex.cloud), select the folder where you want to get a list of broker passwords.
   1. Navigate to **IoT Core**.
   1. In the left-hand panel, select **Brokers**.
   1. Select the appropriate broker from the list.
   1. On the **Overview** page, go to the **Passwords** section.

- CLI {#cli}
  
    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).
    
    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
    
    To get a list of passwords:  
    1. Get a list of brokers in the folder: 
    
        ```
        yc iot broker list
		```
		
		Result:
		```
        +----------------------+--------------------+
        |          ID          |        NAME        |
        +----------------------+--------------------+
        | areg96c8lo********** | broker-with-pass   |
        | arenou2oj4********** | my-broker          |
        +----------------------+--------------------+
        ```
    1. Get a list of broker passwords: 
    
        ```
        yc iot broker password list --broker-name broker-with-pass
        ```
		
		Result:
		```
		+----------------------+---------------------+
        |          ID          |     CREATED AT      |
        +----------------------+---------------------+
        | are0gffs95********** | 2019-12-16 15:34:25 |
        +----------------------+---------------------+
        ```

- API {#api}

  To get a list of broker passwords, use the [listPasswords](../../broker/api-ref/Broker/listPasswords.md) REST API method for the [Broker](../../broker/api-ref/Broker/index.md) resource or the [BrokerService/ListPasswords](../../broker/api-ref/grpc/Broker/listPasswords.md) gRPC API call.

{% endlist %}
   
## Deleting a broker password {#delete}

{% list tabs group=instructions %}

- Management console {#console}

   1. In the [management console](https://console.yandex.cloud), select the folder to delete the broker password from.
   1. Navigate to **IoT Core**.
   1. In the left-hand panel, select **Brokers**.
   1. Select the appropriate broker from the list.
   1. In the row with the password, click ![image](../../../_assets/console-icons/ellipsis.svg) and select **Delete** from the drop-down list.
   1. In the window that opens, click **Delete**.

- CLI {#cli}
  
    If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).
    
    The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.
    
    To delete a password:  
    1. Get a list of broker passwords: 
    
        ```
        yc iot broker password list --broker-name broker-with-pass
        ```
		
		Result:
		```
		+----------------------+---------------------+
        |          ID          |     CREATED AT      |
        +----------------------+---------------------+
        | are0gffs95********** | 2019-12-16 15:34:25 |
        +----------------------+---------------------+
        ```
    1. Delete the password: 
    
        ```
        yc iot broker password delete --broker-name broker-with-pass --password-id are0gffs957e********
        ```
    1. Make sure that the password was deleted: 
        
        ```
        yc iot broker password list --broker-name broker-with-pass
        ```
		
		Result:
		```
		+----+------------+
        | ID | CREATED AT |
        +----+------------+
        +----+------------+
        ```

- API {#api}

  To delete a broker password, use the [deletePassword](../../broker/api-ref/Broker/deletePassword.md) REST API method for the [Broker](../../broker/api-ref/Broker/index.md) resource or the [BrokerService/DeletePassword](../../broker/api-ref/grpc/Broker/deletePassword.md) gRPC API call.

{% endlist %}