Share via


az vm user

Manage user accounts for a VM.

Commands

Name Description Type Status
az vm user delete

Delete a user account from a VM.

Core GA
az vm user reset-ssh

Reset the SSH configuration on a VM.

Core GA
az vm user update

Update a user account for VM. You can use it to update password or ssh key value for VM user.

Core GA

az vm user delete

Delete a user account from a VM.

Also deletes the user home directory on Linux VMs.

az vm user delete --username
                  [--ids]
                  [--name]
                  [--no-wait]
                  [--resource-group]
                  [--subscription]

Examples

Delete a user account.

az vm user delete -u username -n MyVm -g MyResourceGroup

Delete a user on all VMs in a resource group.

az vm user delete -u username --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)

Required Parameters

--username -u

The user name.

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm user reset-ssh

Reset the SSH configuration on a VM.

The extension will restart the SSH service, open the SSH port on your VM, and reset the SSH configuration to default values. The user account (name, password, and SSH keys) are not changed.

az vm user reset-ssh [--ids]
                     [--name]
                     [--no-wait]
                     [--resource-group]
                     [--subscription]

Examples

Reset the SSH configuration.

az vm user reset-ssh -n MyVm -g MyResourceGroup

Reset the SSH server on all VMs in a resource group.

az vm user reset-ssh --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.

az vm user update

Update a user account for VM. You can use it to update password or ssh key value for VM user.

This command uses VMAccessForLinux 1.5 for Linux operating system and VMAccessAgent 2.4 for Window operating system.

az vm user update --username
                  [--ids]
                  [--name]
                  [--no-wait]
                  [--password]
                  [--resource-group]
                  [--ssh-key-value]
                  [--subscription]

Examples

Update a Windows user account. If username does not exist, a new user will be created.

az vm user update -u username -p password -n MyVm -g MyResourceGroup

Update a Linux user account. ("$(< filename)" syntax is not supported on Command Prompt or PowerShell.)

az vm user update -u username --ssh-key-value "$(< ~/.ssh/id_rsa.pub)" -n MyVm -g MyResourceGroup

Update a user on all VMs in a resource group. ("$(< filename)" syntax is not supported on Command Prompt or PowerShell.)

az vm user update -u username --ssh-key-value "$(< ~/.ssh/id_rsa.pub)" --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)

Required Parameters

--username -u

The user name.

Optional Parameters

--ids

One or more resource IDs (space-delimited). It should be a complete resource ID containing all information of 'Resource Id' arguments. You should provide either --ids or other 'Resource Id' arguments.

--name -n

The name of the Virtual Machine. You can configure the default using az configure --defaults vm=<name>.

--no-wait

Do not wait for the long-running operation to finish.

Default value: False
--password -p

The user password.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--ssh-key-value

SSH public key file value or public key file path. This command appends the new public key text to the ~/.ssh/authorized_keys file for the admin user on the VM. This does not replace or remove any existing SSH keys.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose

Increase logging verbosity. Use --debug for full debug logs.