你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzStorageLocalUserSshPublicKey

Creates a SSH public key object, which can be used in Set-AzStorageLocalUser.

Syntax

New-AzStorageLocalUserSshPublicKey
   -Key <String>
   [-Description <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzStorageLocalUserSshPublicKey cmdlet creates a SSH public key object, which can be used in Set-AzStorageLocalUser.

Examples

Example 1: Create SSH public key objects, then create or update local user with the SSH public key objects.

$sshkey1 = New-AzStorageLocalUserSshPublicKey -Key "ssh-rsa keykeykeykeykey=" -Description "sshpulickey name1"

$sshkey2 = New-AzStorageLocalUserSshPublicKey -Key "ssh-rsa keykeykeykeykew=" -Description "sshpulickey name2"

$localuser = Set-AzStorageLocalUser -ResourceGroupName "myresourcegroup" -AccountName "mystorageaccount" -UserName testuser1 -HomeDirectory "/" -SshAuthorizedKey $sshkey1,$sshkey2

$localuser

   ResourceGroupName: myresourcegroup, StorageAccountName: mystorageaccount

Name      Sid                                          HomeDirectory HasSharedKey HasSshKey HasSshPassword PermissionScopes SshAuthorizedKeys             
----      ---                                          ------------- ------------ --------- -------------- ---------------- -----------------             
testuser1 S-1-2-0-0000000000-000000000-0000000000-0000 /                                                                    [ssh-rsa keykeykeykeykey=,...]

$localuser.SshAuthorizedKeys 

Description       Key                     
-----------       ---                     
sshpulickey name1 ssh-rsa keykeykeykeykey=
sshpulickey name2 ssh-rsa keykeykeykeykew=

This first 2 commands create 2 SSH public key objects. The following commands create or update a local user with the SSH public key objects, then show the updated local user properties.

Parameters

-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

-Description

The description of the key. It is used to store the function/usage of the key.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Key

Specify ssh public key, the key data is base64 encoded. The format should be: '<keyType> <keyData>', e.g. ssh-rsa AAAABBBB

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None

Outputs

PSSshPublicKey