Managing device passwords
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.
To start exchanging data and commands between devices and registries, you need to authenticate. This section describes how to manage device passwords for the relevant authentication method.
Note
When an X.509 certificate is used along with a password, the password takes 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 by using the --read-password flag instead of --password.
Adding a password to an existing device
To add a password to an existing device:
- In the management console
, select the folder where you want to add a password to an existing device. - Navigate
to IoT Core and select a registry with the device. - Navigate to the Devices tab and select the device.
- Under Passwords, click Add password.
- In the Password field, enter the password you will use to access the device.
To create a password, you can use this password generator .
Make sure to save the password for later. - Click Add.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
To add a password:
-
Get a list of devices in the registry:
yc iot device --registry-name my-registry listResult:
+----------------------+--------+ | ID | NAME | +----------------------+--------+ | arenak5ciqss******** | second | | areqjd6un3af******** | first | +----------------------+--------+ -
Add a password to the device:
yc iot device password add --device-name first --password Passw0rdForDeviceResult:
device_id: areqjd6un3af******** id: areqjd6un3af******** created_at: "2019-12-16T15:11:36.892167Z"
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the guides on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.
To add a password to a device created with Terraform:
-
In the configuration file, describe the resource you want to create:
-
yandex_iot_core_device: Device properties:registry_id: ID of the registry where the device was created.name: Device name.description: Device description.passwords: List of passwords for username and password authentication.
Here is an example of a resource structure in the configuration file:
resource "yandex_iot_core_device" "my_device" { registry_id = "<registry_ID>" name = "<device_name>" description = "test device for terraform provider documentation" ... passwords = [ "<password>", ] ... }For more on the properties of the
yandex_iot_core_deviceresource, see this provider guide. -
-
In the terminal, navigate to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors detected in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.You can check device passwords using the management console
or this CLI command:yc iot device password list --device-name <device_name>
To add a password to a device, use the addPassword REST API method for the Device resource or the DeviceService/AddPassword gRPC API call.
Setting a password for a device when creating it
For information on how to set a password for a device when creating it, see Creating a device.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating 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 set a password when creating a device:
-
Get a list of registries in the folder:
yc iot registry listResult:
+----------------------+-------------------+ | ID | NAME | +----------------------+-------------------+ | arenou2oj4ct******** | my-registry | +----------------------+-------------------+ -
Create a device with a password:
yc iot device create --registry-name my-registry --name device-with-pass --password Passw0rdForDeviceResult:
id: arepomfambsg******** registry_id: arenou2oj4ct******** created_at: "2019-12-16T15:18:39.358922Z" name: device-with-pass
For information on how to set a password for a device when creating it, see Creating a device.
To set a password for a device when creating it, use the create REST API method for the Device resource or the DeviceService/Create gRPC API call.
Getting a list of device passwords
To view a list of device passwords:
- In the management console
, select the folder where you want to get a list of device passwords. - Navigate
to IoT Core and select a registry with the device. - Navigate to the Devices tab and select the device.
- On the Overview tab, go to the Passwords section to see the list of passwords for the device.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating 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:
-
Get a list of devices in the registry:
yc iot device --registry-name my-registry listResult:
+----------------------+------------------+ | ID | NAME | +----------------------+------------------+ | arenak5ciqss******** | second | | arepomfambsg******** | device-with-pass | | areqjd6un3af******** | first | +----------------------+------------------+ -
Get a list of device passwords:
yc iot device password list --device-name device-with-passResult:
+----------------------+---------------------+ | ID | CREATED AT | +----------------------+---------------------+ | areuin5t7pnd******** | 2019-12-16 15:18:39 | +----------------------+---------------------+
To get a list of device passwords, use the listPasswords REST API method for the Device resource or the DeviceService/ListPasswords gRPC API call.
Deleting a device password
To delete a device password:
- In the management console
, select the folder where you want to delete a device password. - Navigate
to IoT Core and select a registry with the device. - Navigate to the Devices tab and select the device.
- To the right of the password you want to delete, click
→ Delete. - In the window that opens, click Delete.
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating 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:
-
Get a list of device passwords:
yc iot device password list --device-name device-with-passResult:
+----------------------+---------------------+ | ID | CREATED AT | +----------------------+---------------------+ | areuin5t7pnd******** | 2019-12-16 15:18:39 | +----------------------+---------------------+ -
Delete the password:
yc iot device password delete --device-name device-with-pass --password-id areuin5t7pnd******** -
Make sure the password has been deleted:
yc iot device password list --device-name device-with-passResult:
+----+------------+ | ID | CREATED AT | +----+------------+ +----+------------+
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the guides on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To manage infrastructure using Terraform under a service account or user accounts (a Yandex account, a federated account, or a local user), authenticate using the appropriate method.
To delete the password of a device created with Terraform:
-
Open the Terraform configuration file and delete the password value from the
passwordssection in the device description. To remove all passwords, delete the entirepasswordssection.Here is an example of a device description in the Terraform configuration:
resource "yandex_iot_core_device" "my_device" { registry_id = "<registry_ID>" name = "<device_name>" description = "test device for terraform provider documentation" ... passwords = [ "<password>", ] ... }For more on the properties of the
yandex_iot_core_deviceresource, see this provider guide. -
In the terminal, navigate to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is valid, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a list of resources and their properties. No changes will be made at this step. Terraform will show any errors detected in the configuration.
-
Apply the configuration changes:
terraform apply -
Type
yesand press Enter to confirm the changes.You can check device passwords using the management console
or this CLI command:yc iot device password list --device-name <device_name>
To delete a device password, use the deletePassword REST API method for the Device resource or the DeviceService/DeletePassword gRPC API call.