Skip to content

Latest commit

 

History

History
57 lines (44 loc) · 2.2 KB

lnxSshAuthorizedKeysResource.md

File metadata and controls

57 lines (44 loc) · 2.2 KB
title ms.date keywords description ms.topic author manager ms.prod
DSC for Linux nxSshAuthorizedKeys Resource
2016-05-16
powershell,DSC
article
eslesar
dongill
powershell

DSC for Linux nxSshAuthorizedKeys Resource

The nxAuthorizedKeys resource in PowerShell Desired State Configuration (DSC) provides a mechanism to manage authorized ssh keys for a specified user.

Syntax

nxAuthorizedKeys <string> #ResourceName
{
    KeyComment = <string>
    [ Ensure = <string> { Absent | Present }  ]
    [ Username = <string> ]
    [ Key = <string> ]
    [ DependsOn = <string[]> ]

}

Properties

Property Description
KeyComment A unique comment for the key. This is used to uniquely identify keys.
Ensure Specifies whether the key is defined. Set this property to "Absent" to ensure the key does not exist in the user’s authorized keys file. Set it to "Present" to ensure the key is defined in the user’s authorized key file.
Username The username to manage ssh authorized keys for. If not defined, the default user is "root".
Key The contents of the key. This is required if Ensure is set to "Present".
DependsOn Indicates that the configuration of another resource must run before this resource is configured. For example, if the ID of the resource configuration script block that you want to run first is ResourceName and its type is ResourceType, the syntax for using this property is DependsOn = "[ResourceType]ResourceName".

Example

The following example defines a public ssh authorized key for the user "monuser".

Import-DSCResource -Module nx 

Node $node {

nxSshAuthorizedKeys myKey{
   KeyComment = "myKey"
   Ensure = "Present"
   Key = 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEA0b+0xSd07QXRifm3FXj7Pn/DblA6QI5VAkDm6OivFzj3U6qGD1VJ6AAxWPCyMl/qhtpRtxZJDu/TxD8AyZNgc8aN2CljN1hOMbBRvH2q5QPf/nCnnJRaGsrxIqZjyZdYo9ZEEzjZUuMDM5HI1LA9B99k/K6PK2Bc1NLivpu7nbtVG2tLOQs+GefsnHuetsRMwo/+c3LtwYm9M0XfkGjYVCLO4CoFuSQpvX6AB3TedUy6NZ0iuxC0kRGg1rIQTwSRcw+McLhslF0drs33fw6tYdzlLBnnzimShMuiDWiT37WqCRovRGYrGCaEFGTG2e0CN8Co8nryXkyWc6NSDNpMzw== rsa-key-20150401'
   UserName = "monuser"
} 
}