Resource Type: ssh_authorized_key
- Defined in:
- lib/puppet/type/ssh_authorized_key.rb
- Providers:
-
parsed
Overview
Manages SSH authorized keys. Currently only type 2 keys are supported.
In their native habitat, SSH keys usually appear as a single long line, in the format ‘<TYPE> <KEY> <NAME/COMMENT>`. This resource type requires you to split that line into several attributes. Thus, a key that appears in your `~/.ssh/id_rsa.pub` file like this…
ssh-rsa AAAAB3Nza[...]qXfdaQ== nick@magpie.example.com
…would translate to the following resource:
ssh_authorized_key { 'nick@magpie.example.com':
ensure => present,
user => 'nick',
type => 'ssh-rsa',
key => 'AAAAB3Nza[...]qXfdaQ==',
}
To ensure that only the currently approved keys are present, you can purge unmanaged SSH keys on a per-user basis. Do this with the ‘user` resource type’s ‘purge_ssh_keys` attribute:
user { 'nick':
ensure => present,
purge_ssh_keys => true,
}
This will remove any keys in ‘~/.ssh/authorized_keys` that aren’t being managed with ‘ssh_authorized_key` resources. See the documentation of the `user` type for more details.
Autorequires: If Puppet is managing the user account in which this SSH key should be installed, the ‘ssh_authorized_key` resource will autorequire that user.