Managing device passwords

For devices and registries to begin exchanging data and commands, you need to log in. This section describes how to manage device passwords for the relevant authorization method.

Note

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

Adding a password to a device

You can add a password to an already created device or set it when creating a device using the --password parameter.

Note

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

Adding a password to an already created device

If you don't have the Yandex.Cloud command line interface yet, install it.

To add a password:

  1. Get a list of devices in the registry:

    $ yc iot device --registry-name my-registry list
    +----------------------+--------+
    |          ID          |  NAME  |
    +----------------------+--------+
    | arenak5ciqss6pbas5tm | second |
    | areqjd6un3afc3cefuio | first  |
    +----------------------+--------+
    
  2. Add a password to the device:

    $ yc iot device password add --device-name first --password Passw0rdForDevice
    device_id: areqjd6un3afc3cefcvm
    id: areqjd6un3afc3cefuio
    created_at: "2019-12-16T15:11:36.892167Z"
    

Setting a password for a device when creating it

If you don't have the Yandex.Cloud command line interface yet, install it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To set a password when creating a device:

  1. Get a list of registries in the folder:

    $ yc iot registry list
    +----------------------+-------------------+
    |          ID          |       NAME        |
    +----------------------+-------------------+
    | arenou2oj4ct42eq8f4m | my-registry       |
    +----------------------+-------------------+
    
  2. Create a device with a password:

    $ yc iot device create --registry-name my-registry --name device-with-pass --password Passw0rdForDevice
    id: arepomfambsg5biqc25n
    registry_id: arenou2oj4ct42eq8g3n
    created_at: "2019-12-16T15:18:39.358922Z"
    name: device-with-pass
    

Getting a list of device passwords

If you don't have the Yandex.Cloud command line interface yet, install it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To get a list of passwords:

  1. Get a list of devices in the registry:

    $ yc iot device --registry-name my-registry list
    +----------------------+------------------+
    |          ID          |       NAME       |
    +----------------------+------------------+
    | arenak5ciqss6pbas5tm | second           |
    | arepomfambsg5biqc77p | device-with-pass |
    | areqjd6un3afc3cefuio | first            |
    +----------------------+------------------+
    
  2. Get a list of device passwords:

    $ yc iot device password list --device-name device-with-pass
    +----------------------+---------------------+
    |          ID          |     CREATED AT      |
    +----------------------+---------------------+
    | areuin5t7pndvlj6n4tr | 2019-12-16 15:18:39 |
    +----------------------+---------------------+
    

Deleting a device password

If you don't have the Yandex.Cloud command line interface yet, install it.

The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name or --folder-id parameter.

To delete a password:

  1. Get a list of device passwords:

    $ yc iot device password list --device-name device-with-pass
    +----------------------+---------------------+
    |          ID          |     CREATED AT      |
    +----------------------+---------------------+
    | areuin5t7pndvlj6n4tr | 2019-12-16 15:18:39 |
    +----------------------+---------------------+
    
  2. Delete the password:

    $ yc iot device password delete --device-name device-with-pass --password-id areuin5t7pndvlj6n4tr
    
  3. Make sure that the password was deleted:

    $ yc iot device password list --device-name device-with-pass
    +----+------------+
    | ID | CREATED AT |
    +----+------------+
    +----+------------+