summaryrefslogtreecommitdiffstats
path: root/zarb-ml/mageia-sysadm/2010-November/000768.html
diff options
context:
space:
mode:
Diffstat (limited to 'zarb-ml/mageia-sysadm/2010-November/000768.html')
-rw-r--r--zarb-ml/mageia-sysadm/2010-November/000768.html759
1 files changed, 759 insertions, 0 deletions
diff --git a/zarb-ml/mageia-sysadm/2010-November/000768.html b/zarb-ml/mageia-sysadm/2010-November/000768.html
new file mode 100644
index 000000000..e9c27b121
--- /dev/null
+++ b/zarb-ml/mageia-sysadm/2010-November/000768.html
@@ -0,0 +1,759 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+ <HEAD>
+ <TITLE> [Mageia-sysadm] [369] move modules/ssh/manifests/init.pp as modules/ssh/manifests/auth.pp
+ </TITLE>
+ <LINK REL="Index" HREF="index.html" >
+ <LINK REL="made" HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B369%5D%20move%20modules/ssh/manifests/init.pp%20as%0A%09modules/ssh/manifests/auth.pp&In-Reply-To=%3C20101122002550.931383F868%40valstar.mageia.org%3E">
+ <META NAME="robots" CONTENT="index,nofollow">
+ <META http-equiv="Content-Type" content="text/html; charset=us-ascii">
+ <LINK REL="Previous" HREF="000742.html">
+ <LINK REL="Next" HREF="000743.html">
+ </HEAD>
+ <BODY BGCOLOR="#ffffff">
+ <H1>[Mageia-sysadm] [369] move modules/ssh/manifests/init.pp as modules/ssh/manifests/auth.pp</H1>
+ <B>root at mageia.org</B>
+ <A HREF="mailto:mageia-sysadm%40mageia.org?Subject=Re%3A%20%5BMageia-sysadm%5D%20%5B369%5D%20move%20modules/ssh/manifests/init.pp%20as%0A%09modules/ssh/manifests/auth.pp&In-Reply-To=%3C20101122002550.931383F868%40valstar.mageia.org%3E"
+ TITLE="[Mageia-sysadm] [369] move modules/ssh/manifests/init.pp as modules/ssh/manifests/auth.pp">root at mageia.org
+ </A><BR>
+ <I>Mon Nov 22 01:25:50 CET 2010</I>
+ <P><UL>
+ <LI>Previous message: <A HREF="000742.html">[Mageia-sysadm] [368] move modules/ssh_auth as modules/ssh
+</A></li>
+ <LI>Next message: <A HREF="000743.html">[Mageia-sysadm] [370] valstar is the ssh keymaster
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#768">[ date ]</a>
+ <a href="thread.html#768">[ thread ]</a>
+ <a href="subject.html#768">[ subject ]</a>
+ <a href="author.html#768">[ author ]</a>
+ </LI>
+ </UL>
+ <HR>
+<!--beginarticle-->
+<PRE>Revision: 369
+Author: blino
+Date: 2010-11-22 01:25:50 +0100 (Mon, 22 Nov 2010)
+Log Message:
+-----------
+move modules/ssh/manifests/init.pp as modules/ssh/manifests/auth.pp
+
+Added Paths:
+-----------
+ puppet/modules/ssh/manifests/auth.pp
+
+Removed Paths:
+-------------
+ puppet/modules/ssh/manifests/init.pp
+
+Copied: puppet/modules/ssh/manifests/auth.pp (from rev 368, puppet/modules/ssh/manifests/init.pp)
+===================================================================
+--- puppet/modules/ssh/manifests/auth.pp (rev 0)
++++ puppet/modules/ssh/manifests/auth.pp 2010-11-22 00:25:50 UTC (rev 369)
+@@ -0,0 +1,336 @@
++# =========
++# ssh::auth
++# =========
++#
++# The latest official release and documentation for ssh::auth can always
++# be found at <A HREF="http://reductivelabs.com/trac/puppet/wiki/Recipes/ModuleSSHAuth">http://reductivelabs.com/trac/puppet/wiki/Recipes/ModuleSSHAuth</A> .
++#
++# Version: 0.3.2
++# Release date: 2009-12-29
++
++class ssh::auth {
++
++$keymaster_storage = &quot;/var/lib/keys&quot;
++
++Exec { path =&gt; &quot;/usr/bin:/usr/sbin:/bin:/sbin&quot; }
++Notify { withpath =&gt; false }
++
++
++##########################################################################
++
++
++# ssh::auth::key
++
++# Declare keys. The approach here is just to define a bunch of
++# virtual resources, representing key files on the keymaster, client,
++# and server. The virtual keys are then realized by
++# ssh::auth::{keymaster,client,server}, respectively. The reason for
++# doing things that way is that it makes ssh::auth::key into a &quot;one
++# stop shop&quot; where users can declare their keys with all of their
++# parameters, whether those parameters apply to the keymaster, server,
++# or client. The real work of creating, installing, and removing keys
++# is done in the private definitions called by the virtual resources:
++# ssh_auth_key_{master,server,client}.
++
++define key ($ensure = &quot;present&quot;, $filename = &quot;&quot;, $force = false, $group = &quot;puppet&quot;, $home = &quot;&quot;, $keytype = &quot;rsa&quot;, $length = 2048, $maxdays = &quot;&quot;, $mindate = &quot;&quot;, $options = &quot;&quot;, $user = &quot;&quot;) {
++
++ ssh_auth_key_namecheck { &quot;${title}-title&quot;: parm =&gt; &quot;title&quot;, value =&gt; $title }
++
++ # apply defaults
++ $_filename = $filename ? { &quot;&quot; =&gt; &quot;id_${keytype}&quot;, default =&gt; $filename }
++ $_length = $keytype ? { &quot;rsa&quot; =&gt; $length, &quot;dsa&quot; =&gt; 1024 }
++ $_user = $user ? {
++ &quot;&quot; =&gt; regsubst($title, '^([^@]*)@?.*$', '\1'),
++ default =&gt; $user,
++ }
++ $_home = $home ? { &quot;&quot; =&gt; &quot;/home/$_user&quot;, default =&gt; $home }
++
++ ssh_auth_key_namecheck { &quot;${title}-filename&quot;: parm =&gt; &quot;filename&quot;, value =&gt; $_filename }
++
++ @ssh_auth_key_master { $title:
++ ensure =&gt; $ensure,
++ force =&gt; $force,
++ keytype =&gt; $keytype,
++ length =&gt; $_length,
++ maxdays =&gt; $maxdays,
++ mindate =&gt; $mindate,
++ }
++ @ssh_auth_key_client { $title:
++ ensure =&gt; $ensure,
++ filename =&gt; $_filename,
++ group =&gt; $group,
++ home =&gt; $_home,
++ user =&gt; $_user,
++ }
++ @ssh_auth_key_server { $title:
++ ensure =&gt; $ensure,
++ group =&gt; $group,
++ home =&gt; $_home,
++ options =&gt; $options,
++ user =&gt; $_user,
++ }
++}
++
++
++##########################################################################
++
++
++# ssh::auth::keymaster
++#
++# Keymaster host:
++# Create key storage; create, regenerate, and remove key pairs
++
++class keymaster {
++
++ # Set up key storage
++
++ file { $ssh::auth::keymaster_storage:
++ ensure =&gt; directory,
++ owner =&gt; puppet,
++ group =&gt; puppet,
++ mode =&gt; 644,
++ }
++
++ # Realize all virtual master keys
++ Ssh_auth_key_master &lt;| |&gt;
++
++} # class keymaster
++
++
++##########################################################################
++
++
++# ssh::auth::client
++#
++# Install generated key pairs onto clients
++
++define client ($ensure = &quot;&quot;, $filename = &quot;&quot;, $group = &quot;&quot;, $home = &quot;&quot;, $user = &quot;&quot;) {
++
++ # Realize the virtual client keys.
++ # Override the defaults set in ssh::auth::key, as needed.
++ if $ensure { Ssh_auth_key_client &lt;| title == $title |&gt; { ensure =&gt; $ensure } }
++ if $filename { Ssh_auth_key_client &lt;| title == $title |&gt; { filename =&gt; $filename } }
++ if $group { Ssh_auth_key_client &lt;| title == $title |&gt; { group =&gt; $group } }
++
++ if $user { Ssh_auth_key_client &lt;| title == $title |&gt; { user =&gt; $user, home =&gt; &quot;/home/$user&quot; } }
++ if $home { Ssh_auth_key_client &lt;| title == $title |&gt; { home =&gt; $home } }
++
++ realize Ssh_auth_key_client[$title]
++
++} # define client
++
++
++##########################################################################
++
++
++# ssh::auth::server
++#
++# Install public keys onto clients
++
++define server ($ensure = &quot;&quot;, $group = &quot;&quot;, $home = &quot;&quot;, $options = &quot;&quot;, $user = &quot;&quot;) {
++
++ # Realize the virtual server keys.
++ # Override the defaults set in ssh::auth::key, as needed.
++ if $ensure { Ssh_auth_key_server &lt;| title == $title |&gt; { ensure =&gt; $ensure } }
++ if $group { Ssh_auth_key_server &lt;| title == $title |&gt; { group =&gt; $group } }
++ if $options { Ssh_auth_key_server &lt;| title == $title |&gt; { options =&gt; $options } }
++
++ if $user { Ssh_auth_key_server &lt;| title == $title |&gt; { user =&gt; $user, home =&gt; &quot;/home/$user&quot; } }
++ if $home { Ssh_auth_key_server &lt;| title == $title |&gt; { home =&gt; $home } }
++
++ realize Ssh_auth_key_server[$title]
++
++} # define server
++
++} # class ssh::auth
++
++
++##########################################################################
++
++
++# ssh_auth_key_master
++#
++# Create/regenerate/remove a key pair on the keymaster.
++# This definition is private, i.e. it is not intended to be called directly by users.
++# ssh::auth::key calls it to create virtual keys, which are realized in ssh::auth::keymaster.
++
++define ssh_auth_key_master ($ensure, $force, $keytype, $length, $maxdays, $mindate) {
++
++ Exec { path =&gt; &quot;/usr/bin:/usr/sbin:/bin:/sbin&quot; }
++ File {
++ owner =&gt; puppet,
++ group =&gt; puppet,
++ mode =&gt; 600,
++ }
++
++ $keydir = &quot;${ssh::auth::keymaster_storage}/${title}&quot;
++ $keyfile = &quot;${keydir}/key&quot;
++
++ file {
++ &quot;$keydir&quot;:
++ ensure =&gt; directory,
++ mode =&gt; 644;
++ &quot;$keyfile&quot;:
++ ensure =&gt; $ensure;
++ &quot;${keyfile}.pub&quot;:
++ ensure =&gt; $ensure,
++ mode =&gt; 644;
++ }
++
++ if $ensure == &quot;present&quot; {
++
++ # Remove the existing key pair, if
++ # * $force is true, or
++ # * $maxdays or $mindate criteria aren't met, or
++ # * $keytype or $length have changed
++
++ $keycontent = file(&quot;${keyfile}.pub&quot;, &quot;/dev/null&quot;)
++ if $keycontent {
++
++ if $force {
++ $reason = &quot;force=true&quot;
++ }
++ if !$reason and $mindate and generate(&quot;/usr/bin/find&quot;, $keyfile, &quot;!&quot;, &quot;-newermt&quot;, &quot;${mindate}&quot;) {
++ $reason = &quot;created before ${mindate}&quot;
++ }
++ if !$reason and $maxdays and generate(&quot;/usr/bin/find&quot;, $keyfile, &quot;-mtime&quot;, &quot;+${maxdays}&quot;) {
++ $reason = &quot;older than ${maxdays} days&quot;
++ }
++ if !$reason and $keycontent =~ /^ssh-... [^ ]+ (...) (\d+)$/ {
++ if $keytype != $1 { $reason = &quot;keytype changed: $1 -&gt; $keytype&quot; }
++ else { if $length != $2 { $reason = &quot;length changed: $2 -&gt; $length&quot; } }
++ }
++ if $reason {
++ exec { &quot;Revoke previous key ${title}: ${reason}&quot;:
++ command =&gt; &quot;rm $keyfile ${keyfile}.pub&quot;,
++ before =&gt; Exec[&quot;Create key $title: $keytype, $length bits&quot;],
++ }
++ }
++ }
++
++ # Create the key pair.
++ # We &quot;repurpose&quot; the comment field in public keys on the keymaster to
++ # store data about the key, i.e. $keytype and $length. This avoids
++ # having to rerun ssh-keygen -l on every key at every run to determine
++ # the key length.
++ exec { &quot;Create key $title: $keytype, $length bits&quot;:
++ command =&gt; &quot;ssh-keygen -t ${keytype} -b ${length} -f ${keyfile} -C \&quot;${keytype} ${length}\&quot; -N \&quot;\&quot;&quot;,
++ user =&gt; &quot;puppet&quot;,
++ group =&gt; &quot;puppet&quot;,
++ creates =&gt; $keyfile,
++ require =&gt; File[$keydir],
++ before =&gt; File[$keyfile, &quot;${keyfile}.pub&quot;],
++ }
++
++ } # if $ensure == &quot;present&quot;
++
++} # define ssh_auth_key_master
++
++
++##########################################################################
++
++
++# ssh_auth_key_client
++#
++# Install a key pair into a user's account.
++# This definition is private, i.e. it is not intended to be called directly by users.
++
++define ssh_auth_key_client ($ensure, $filename, $group, $home, $user) {
++
++ File {
++ owner =&gt; $user,
++ group =&gt; $group,
++ mode =&gt; 600,
++ require =&gt; [ User[$user], File[$home]],
++ }
++
++ $key_src_file = &quot;${ssh::auth::keymaster_storage}/${title}/key&quot; # on the keymaster
++ $key_tgt_file = &quot;${home}/.ssh/${filename}&quot; # on the client
++
++ $key_src_content_pub = file(&quot;${key_src_file}.pub&quot;, &quot;/dev/null&quot;)
++ if $ensure == &quot;absent&quot; or $key_src_content_pub =~ /^(ssh-...) ([^ ]+)/ {
++ $keytype = $1
++ $modulus = $2
++ file {
++ $key_tgt_file:
++ ensure =&gt; $ensure,
++ content =&gt; file($key_src_file, &quot;/dev/null&quot;);
++ &quot;${key_tgt_file}.pub&quot;:
++ ensure =&gt; $ensure,
++ content =&gt; &quot;$keytype $modulus $title\n&quot;,
++ mode =&gt; 644;
++ }
++ } else {
++ notify { &quot;Private key file $key_src_file for key $title not found on keymaster; skipping ensure =&gt; present&quot;: }
++ }
++
++} # define ssh_auth_key_client
++
++
++##########################################################################
++
++
++# ssh_auth_key_server
++#
++# Install a public key into a server user's authorized_keys(5) file.
++# This definition is private, i.e. it is not intended to be called directly by users.
++
++define ssh_auth_key_server ($ensure, $group, $home, $options, $user) {
++
++ # on the keymaster:
++ $key_src_dir = &quot;${ssh::auth::keymaster_storage}/${title}&quot;
++ $key_src_file = &quot;${key_src_dir}/key.pub&quot;
++ # on the server:
++ $key_tgt_file = &quot;${home}/.ssh/authorized_keys&quot;
++
++ File {
++ owner =&gt; $user,
++ group =&gt; $group,
++ require =&gt; User[$user],
++ mode =&gt; 600,
++ }
++ Ssh_authorized_key {
++ user =&gt; $user,
++ target =&gt; $key_tgt_file,
++ }
++
++ if $ensure == &quot;absent&quot; {
++ ssh_authorized_key { $title: ensure =&gt; &quot;absent&quot; }
++ }
++ else {
++ $key_src_content = file($key_src_file, &quot;/dev/null&quot;)
++ if ! $key_src_content {
++ notify { &quot;Public key file $key_src_file for key $title not found on keymaster; skipping ensure =&gt; present&quot;: }
++ } else { if $ensure == &quot;present&quot; and $key_src_content !~ /^(ssh-...) ([^ ]*)/ {
++ err(&quot;Can't parse public key file $key_src_file&quot;)
++ notify { &quot;Can't parse public key file $key_src_file for key $title on the keymaster: skipping ensure =&gt; $ensure&quot;: }
++ } else {
++ $keytype = $1
++ $modulus = $2
++ ssh_authorized_key { $title:
++ ensure =&gt; &quot;present&quot;,
++ type =&gt; $keytype,
++ key =&gt; $modulus,
++ options =&gt; $options ? { &quot;&quot; =&gt; undef, default =&gt; $options },
++ }
++ }} # if ... else ... else
++ } # if ... else
++
++} # define ssh_auth_key_server
++
++
++##########################################################################
++
++
++# ssh_auth_key_namecheck
++#
++# Check a name (e.g. key title or filename) for the allowed form
++
++define ssh_auth_key_namecheck ($parm, $value) {
++ if $value !~ /^[A-Za-z0-9]/ {
++ fail(&quot;ssh::auth::key: $parm '$value' not allowed: must begin with a letter or digit&quot;)
++ }
++ if $value !~ /^[A-Za-z0-9_.:@-]+$/ {
++ fail(&quot;ssh::auth::key: $parm '$value' not allowed: may only contain the characters A-Za-z0-9_.:@-&quot;)
++ }
++} # define namecheck
+
+Deleted: puppet/modules/ssh/manifests/init.pp
+===================================================================
+--- puppet/modules/ssh/manifests/init.pp 2010-11-22 00:25:33 UTC (rev 368)
++++ puppet/modules/ssh/manifests/init.pp 2010-11-22 00:25:50 UTC (rev 369)
+@@ -1,336 +0,0 @@
+-# =========
+-# ssh::auth
+-# =========
+-#
+-# The latest official release and documentation for ssh::auth can always
+-# be found at <A HREF="http://reductivelabs.com/trac/puppet/wiki/Recipes/ModuleSSHAuth">http://reductivelabs.com/trac/puppet/wiki/Recipes/ModuleSSHAuth</A> .
+-#
+-# Version: 0.3.2
+-# Release date: 2009-12-29
+-
+-class ssh::auth {
+-
+-$keymaster_storage = &quot;/var/lib/keys&quot;
+-
+-Exec { path =&gt; &quot;/usr/bin:/usr/sbin:/bin:/sbin&quot; }
+-Notify { withpath =&gt; false }
+-
+-
+-##########################################################################
+-
+-
+-# ssh::auth::key
+-
+-# Declare keys. The approach here is just to define a bunch of
+-# virtual resources, representing key files on the keymaster, client,
+-# and server. The virtual keys are then realized by
+-# ssh::auth::{keymaster,client,server}, respectively. The reason for
+-# doing things that way is that it makes ssh::auth::key into a &quot;one
+-# stop shop&quot; where users can declare their keys with all of their
+-# parameters, whether those parameters apply to the keymaster, server,
+-# or client. The real work of creating, installing, and removing keys
+-# is done in the private definitions called by the virtual resources:
+-# ssh_auth_key_{master,server,client}.
+-
+-define key ($ensure = &quot;present&quot;, $filename = &quot;&quot;, $force = false, $group = &quot;puppet&quot;, $home = &quot;&quot;, $keytype = &quot;rsa&quot;, $length = 2048, $maxdays = &quot;&quot;, $mindate = &quot;&quot;, $options = &quot;&quot;, $user = &quot;&quot;) {
+-
+- ssh_auth_key_namecheck { &quot;${title}-title&quot;: parm =&gt; &quot;title&quot;, value =&gt; $title }
+-
+- # apply defaults
+- $_filename = $filename ? { &quot;&quot; =&gt; &quot;id_${keytype}&quot;, default =&gt; $filename }
+- $_length = $keytype ? { &quot;rsa&quot; =&gt; $length, &quot;dsa&quot; =&gt; 1024 }
+- $_user = $user ? {
+- &quot;&quot; =&gt; regsubst($title, '^([^@]*)@?.*$', '\1'),
+- default =&gt; $user,
+- }
+- $_home = $home ? { &quot;&quot; =&gt; &quot;/home/$_user&quot;, default =&gt; $home }
+-
+- ssh_auth_key_namecheck { &quot;${title}-filename&quot;: parm =&gt; &quot;filename&quot;, value =&gt; $_filename }
+-
+- @ssh_auth_key_master { $title:
+- ensure =&gt; $ensure,
+- force =&gt; $force,
+- keytype =&gt; $keytype,
+- length =&gt; $_length,
+- maxdays =&gt; $maxdays,
+- mindate =&gt; $mindate,
+- }
+- @ssh_auth_key_client { $title:
+- ensure =&gt; $ensure,
+- filename =&gt; $_filename,
+- group =&gt; $group,
+- home =&gt; $_home,
+- user =&gt; $_user,
+- }
+- @ssh_auth_key_server { $title:
+- ensure =&gt; $ensure,
+- group =&gt; $group,
+- home =&gt; $_home,
+- options =&gt; $options,
+- user =&gt; $_user,
+- }
+-}
+-
+-
+-##########################################################################
+-
+-
+-# ssh::auth::keymaster
+-#
+-# Keymaster host:
+-# Create key storage; create, regenerate, and remove key pairs
+-
+-class keymaster {
+-
+- # Set up key storage
+-
+- file { $ssh::auth::keymaster_storage:
+- ensure =&gt; directory,
+- owner =&gt; puppet,
+- group =&gt; puppet,
+- mode =&gt; 644,
+- }
+-
+- # Realize all virtual master keys
+- Ssh_auth_key_master &lt;| |&gt;
+-
+-} # class keymaster
+-
+-
+-##########################################################################
+-
+-
+-# ssh::auth::client
+-#
+-# Install generated key pairs onto clients
+-
+-define client ($ensure = &quot;&quot;, $filename = &quot;&quot;, $group = &quot;&quot;, $home = &quot;&quot;, $user = &quot;&quot;) {
+-
+- # Realize the virtual client keys.
+- # Override the defaults set in ssh::auth::key, as needed.
+- if $ensure { Ssh_auth_key_client &lt;| title == $title |&gt; { ensure =&gt; $ensure } }
+- if $filename { Ssh_auth_key_client &lt;| title == $title |&gt; { filename =&gt; $filename } }
+- if $group { Ssh_auth_key_client &lt;| title == $title |&gt; { group =&gt; $group } }
+-
+- if $user { Ssh_auth_key_client &lt;| title == $title |&gt; { user =&gt; $user, home =&gt; &quot;/home/$user&quot; } }
+- if $home { Ssh_auth_key_client &lt;| title == $title |&gt; { home =&gt; $home } }
+-
+- realize Ssh_auth_key_client[$title]
+-
+-} # define client
+-
+-
+-##########################################################################
+-
+-
+-# ssh::auth::server
+-#
+-# Install public keys onto clients
+-
+-define server ($ensure = &quot;&quot;, $group = &quot;&quot;, $home = &quot;&quot;, $options = &quot;&quot;, $user = &quot;&quot;) {
+-
+- # Realize the virtual server keys.
+- # Override the defaults set in ssh::auth::key, as needed.
+- if $ensure { Ssh_auth_key_server &lt;| title == $title |&gt; { ensure =&gt; $ensure } }
+- if $group { Ssh_auth_key_server &lt;| title == $title |&gt; { group =&gt; $group } }
+- if $options { Ssh_auth_key_server &lt;| title == $title |&gt; { options =&gt; $options } }
+-
+- if $user { Ssh_auth_key_server &lt;| title == $title |&gt; { user =&gt; $user, home =&gt; &quot;/home/$user&quot; } }
+- if $home { Ssh_auth_key_server &lt;| title == $title |&gt; { home =&gt; $home } }
+-
+- realize Ssh_auth_key_server[$title]
+-
+-} # define server
+-
+-} # class ssh::auth
+-
+-
+-##########################################################################
+-
+-
+-# ssh_auth_key_master
+-#
+-# Create/regenerate/remove a key pair on the keymaster.
+-# This definition is private, i.e. it is not intended to be called directly by users.
+-# ssh::auth::key calls it to create virtual keys, which are realized in ssh::auth::keymaster.
+-
+-define ssh_auth_key_master ($ensure, $force, $keytype, $length, $maxdays, $mindate) {
+-
+- Exec { path =&gt; &quot;/usr/bin:/usr/sbin:/bin:/sbin&quot; }
+- File {
+- owner =&gt; puppet,
+- group =&gt; puppet,
+- mode =&gt; 600,
+- }
+-
+- $keydir = &quot;${ssh::auth::keymaster_storage}/${title}&quot;
+- $keyfile = &quot;${keydir}/key&quot;
+-
+- file {
+- &quot;$keydir&quot;:
+- ensure =&gt; directory,
+- mode =&gt; 644;
+- &quot;$keyfile&quot;:
+- ensure =&gt; $ensure;
+- &quot;${keyfile}.pub&quot;:
+- ensure =&gt; $ensure,
+- mode =&gt; 644;
+- }
+-
+- if $ensure == &quot;present&quot; {
+-
+- # Remove the existing key pair, if
+- # * $force is true, or
+- # * $maxdays or $mindate criteria aren't met, or
+- # * $keytype or $length have changed
+-
+- $keycontent = file(&quot;${keyfile}.pub&quot;, &quot;/dev/null&quot;)
+- if $keycontent {
+-
+- if $force {
+- $reason = &quot;force=true&quot;
+- }
+- if !$reason and $mindate and generate(&quot;/usr/bin/find&quot;, $keyfile, &quot;!&quot;, &quot;-newermt&quot;, &quot;${mindate}&quot;) {
+- $reason = &quot;created before ${mindate}&quot;
+- }
+- if !$reason and $maxdays and generate(&quot;/usr/bin/find&quot;, $keyfile, &quot;-mtime&quot;, &quot;+${maxdays}&quot;) {
+- $reason = &quot;older than ${maxdays} days&quot;
+- }
+- if !$reason and $keycontent =~ /^ssh-... [^ ]+ (...) (\d+)$/ {
+- if $keytype != $1 { $reason = &quot;keytype changed: $1 -&gt; $keytype&quot; }
+- else { if $length != $2 { $reason = &quot;length changed: $2 -&gt; $length&quot; } }
+- }
+- if $reason {
+- exec { &quot;Revoke previous key ${title}: ${reason}&quot;:
+- command =&gt; &quot;rm $keyfile ${keyfile}.pub&quot;,
+- before =&gt; Exec[&quot;Create key $title: $keytype, $length bits&quot;],
+- }
+- }
+- }
+-
+- # Create the key pair.
+- # We &quot;repurpose&quot; the comment field in public keys on the keymaster to
+- # store data about the key, i.e. $keytype and $length. This avoids
+- # having to rerun ssh-keygen -l on every key at every run to determine
+- # the key length.
+- exec { &quot;Create key $title: $keytype, $length bits&quot;:
+- command =&gt; &quot;ssh-keygen -t ${keytype} -b ${length} -f ${keyfile} -C \&quot;${keytype} ${length}\&quot; -N \&quot;\&quot;&quot;,
+- user =&gt; &quot;puppet&quot;,
+- group =&gt; &quot;puppet&quot;,
+- creates =&gt; $keyfile,
+- require =&gt; File[$keydir],
+- before =&gt; File[$keyfile, &quot;${keyfile}.pub&quot;],
+- }
+-
+- } # if $ensure == &quot;present&quot;
+-
+-} # define ssh_auth_key_master
+-
+-
+-##########################################################################
+-
+-
+-# ssh_auth_key_client
+-#
+-# Install a key pair into a user's account.
+-# This definition is private, i.e. it is not intended to be called directly by users.
+-
+-define ssh_auth_key_client ($ensure, $filename, $group, $home, $user) {
+-
+- File {
+- owner =&gt; $user,
+- group =&gt; $group,
+- mode =&gt; 600,
+- require =&gt; [ User[$user], File[$home]],
+- }
+-
+- $key_src_file = &quot;${ssh::auth::keymaster_storage}/${title}/key&quot; # on the keymaster
+- $key_tgt_file = &quot;${home}/.ssh/${filename}&quot; # on the client
+-
+- $key_src_content_pub = file(&quot;${key_src_file}.pub&quot;, &quot;/dev/null&quot;)
+- if $ensure == &quot;absent&quot; or $key_src_content_pub =~ /^(ssh-...) ([^ ]+)/ {
+- $keytype = $1
+- $modulus = $2
+- file {
+- $key_tgt_file:
+- ensure =&gt; $ensure,
+- content =&gt; file($key_src_file, &quot;/dev/null&quot;);
+- &quot;${key_tgt_file}.pub&quot;:
+- ensure =&gt; $ensure,
+- content =&gt; &quot;$keytype $modulus $title\n&quot;,
+- mode =&gt; 644;
+- }
+- } else {
+- notify { &quot;Private key file $key_src_file for key $title not found on keymaster; skipping ensure =&gt; present&quot;: }
+- }
+-
+-} # define ssh_auth_key_client
+-
+-
+-##########################################################################
+-
+-
+-# ssh_auth_key_server
+-#
+-# Install a public key into a server user's authorized_keys(5) file.
+-# This definition is private, i.e. it is not intended to be called directly by users.
+-
+-define ssh_auth_key_server ($ensure, $group, $home, $options, $user) {
+-
+- # on the keymaster:
+- $key_src_dir = &quot;${ssh::auth::keymaster_storage}/${title}&quot;
+- $key_src_file = &quot;${key_src_dir}/key.pub&quot;
+- # on the server:
+- $key_tgt_file = &quot;${home}/.ssh/authorized_keys&quot;
+-
+- File {
+- owner =&gt; $user,
+- group =&gt; $group,
+- require =&gt; User[$user],
+- mode =&gt; 600,
+- }
+- Ssh_authorized_key {
+- user =&gt; $user,
+- target =&gt; $key_tgt_file,
+- }
+-
+- if $ensure == &quot;absent&quot; {
+- ssh_authorized_key { $title: ensure =&gt; &quot;absent&quot; }
+- }
+- else {
+- $key_src_content = file($key_src_file, &quot;/dev/null&quot;)
+- if ! $key_src_content {
+- notify { &quot;Public key file $key_src_file for key $title not found on keymaster; skipping ensure =&gt; present&quot;: }
+- } else { if $ensure == &quot;present&quot; and $key_src_content !~ /^(ssh-...) ([^ ]*)/ {
+- err(&quot;Can't parse public key file $key_src_file&quot;)
+- notify { &quot;Can't parse public key file $key_src_file for key $title on the keymaster: skipping ensure =&gt; $ensure&quot;: }
+- } else {
+- $keytype = $1
+- $modulus = $2
+- ssh_authorized_key { $title:
+- ensure =&gt; &quot;present&quot;,
+- type =&gt; $keytype,
+- key =&gt; $modulus,
+- options =&gt; $options ? { &quot;&quot; =&gt; undef, default =&gt; $options },
+- }
+- }} # if ... else ... else
+- } # if ... else
+-
+-} # define ssh_auth_key_server
+-
+-
+-##########################################################################
+-
+-
+-# ssh_auth_key_namecheck
+-#
+-# Check a name (e.g. key title or filename) for the allowed form
+-
+-define ssh_auth_key_namecheck ($parm, $value) {
+- if $value !~ /^[A-Za-z0-9]/ {
+- fail(&quot;ssh::auth::key: $parm '$value' not allowed: must begin with a letter or digit&quot;)
+- }
+- if $value !~ /^[A-Za-z0-9_.:@-]+$/ {
+- fail(&quot;ssh::auth::key: $parm '$value' not allowed: may only contain the characters A-Za-z0-9_.:@-&quot;)
+- }
+-} # define namecheck
+-------------- next part --------------
+An HTML attachment was scrubbed...
+URL: &lt;/pipermail/mageia-sysadm/attachments/20101122/7a65dfdd/attachment-0001.html&gt;
+</PRE>
+
+
+
+
+<!--endarticle-->
+ <HR>
+ <P><UL>
+ <!--threads-->
+ <LI>Previous message: <A HREF="000742.html">[Mageia-sysadm] [368] move modules/ssh_auth as modules/ssh
+</A></li>
+ <LI>Next message: <A HREF="000743.html">[Mageia-sysadm] [370] valstar is the ssh keymaster
+</A></li>
+ <LI> <B>Messages sorted by:</B>
+ <a href="date.html#768">[ date ]</a>
+ <a href="thread.html#768">[ thread ]</a>
+ <a href="subject.html#768">[ subject ]</a>
+ <a href="author.html#768">[ author ]</a>
+ </LI>
+ </UL>
+
+<hr>
+<a href="https://www.mageia.org/mailman/listinfo/mageia-sysadm">More information about the Mageia-sysadm
+mailing list</a><br>
+</body></html>