Set-AzStorageLocalUser
Creates or updates a specified local user in a storage account.
Syntax
Set-AzStorageLocalUser
[-ResourceGroupName] <String>
[-StorageAccountName] <String>
-UserName <String>
[-HomeDirectory <String>]
[-SshAuthorizedKey <PSSshPublicKey[]>]
[-PermissionScope <PSPermissionScope[]>]
[-HasSharedKey <Boolean>]
[-HasSshKey <Boolean>]
[-HasSshPassword <Boolean>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzStorageLocalUser
-StorageAccount <PSStorageAccount>
-UserName <String>
[-HomeDirectory <String>]
[-SshAuthorizedKey <PSSshPublicKey[]>]
[-PermissionScope <PSPermissionScope[]>]
[-HasSharedKey <Boolean>]
[-HasSshKey <Boolean>]
[-HasSshPassword <Boolean>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Set-AzStorageLocalUser cmdlet creates or updates a specified local user in a storage account. To run this cmdlet, the storage account must has already set EnableLocalUser as true.
Examples
Example 1: Create or update a local user
$sshkey1 = New-AzStorageLocalUserSshPublicKey -Key "ssh-rsa base64encodedkey=" -Description "sshpublickey name1"
$permissionScope1 = New-AzStorageLocalUserPermissionScope -Permission rw -Service blob -ResourceName container1
$localuser = Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -SshAuthorizedKey $sshkey1 -PermissionScope $permissionScope1 -HasSharedKey $true -HasSshKey $true -HasSshPassword $true
$localuser
ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount
Name Sid HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes
---- --- ------------- ------------ --------- -------------- ----------------
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 / True True True [container1]
$localuser.SshAuthorizedKeys
Description Key
----------- ---
sshpublickey name1 ssh-rsa base64encodedkey=
$localuser.PermissionScopes
Permissions Service ResourceName
----------- ------- ------------
rw blob container1
The first command creates a local SSH public key object. Note that the key follows the format of <algorithm> <data>
where data is the base64 encoded contents of the public key.
The second command creates a local permission scope object that defines the container level access for the local user.
The third command creates or updates the local user, using the local objects from the first 2 commands.
The final command shows the local user properties.
Example 2: Create or update a local user by input permission scope and ssh key with json
Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -HasSharedKey $true -HasSshKey $true -HasSshPassword $true `
-SshAuthorizedKey (@{
Description="sshpulickey name1";
Key="ssh-rsa base64encodedkey=";
},
@{
Description="sshpulickey name2";
Key="ssh-rsa otherbase64encodedkey=";
}) `
-PermissionScope (@{
Permissions="rw";
Service="blob";
ResourceName="container1";
},
@{
Permissions="rwd";
Service="share";
ResourceName="share1";
})
ResourceGroupName: weitry, StorageAccountName: weisftp3
Name Sid HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes
---- --- ------------- ------------ --------- -------------- ----------------
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 / True True True [container1,...]
This command creates or updates a local user by input permission scope and ssh key with json.
Parameters
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-HasSharedKey
Whether shared key exists. Set it to false to remove existing shared key.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-HasSshKey
Whether SSH key exists. Set it to false to remove existing SSH key.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-HasSshPassword
Whether SSH password exists. Set it to false to remove existing SSH password.
Type: | Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-HomeDirectory
Local user home directory
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-PermissionScope
The permission scopes of the local user. Get the object with New-AzStorageLocalUserPermissionScope cmdlet.
Type: | PSPermissionScope[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
Resource Group Name.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SshAuthorizedKey
Local user ssh authorized keys for SFTP. Get the object with New-AzStorageLocalUserSshPublicKey cmdlet.
Type: | PSSshPublicKey[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-StorageAccount
Storage account object
Type: | PSStorageAccount |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-StorageAccountName
Storage Account Name.
Type: | String |
Aliases: | AccountName |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-UserName
The name of local user. The username must contain lowercase letters and numbers only. It must be unique only within the storage account.
Type: | String |
Aliases: | Name |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
Outputs
Azure PowerShell