Puppet Function: ssh::parse_ssh_pubkey
- Defined in:
- functions/parse_ssh_pubkey.pp
- Function type:
- Puppet Language
Overview
Take an ssh pubkey that looks like:
ssh-rsa jdlkfgjsdfo;i... user@domain.com
and turn it into a hash, usable in the ssh_authorized_key type
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'functions/parse_ssh_pubkey.pp', line 9
function ssh::parse_ssh_pubkey(String $key) {
$split = $key.split(' ')
$base = {
'key' => $split[1],
'type' => $split[0],
}
$user = $split[2]
if $user {
$out = $base + {
'user' => $user.split('@')[0],
}
}
else {
$out = $base
}
$out
}
|