[Mageia-sysadm] [696] add script to help adding ssh keys

root at mageia.org root at mageia.org
Fri Jan 7 14:26:08 CET 2011


Revision: 696
Author:   boklm
Date:     2011-01-07 14:26:08 +0100 (Fri, 07 Jan 2011)
Log Message:
-----------
add script to help adding ssh keys

Modified Paths:
--------------
    puppet/manifests/nodes.pp
    puppet/modules/buildsystem/manifests/init.pp

Added Paths:
-----------
    puppet/modules/buildsystem/templates/mgacreatehome

Modified: puppet/manifests/nodes.pp
===================================================================
--- puppet/manifests/nodes.pp	2011-01-07 02:46:13 UTC (rev 695)
+++ puppet/manifests/nodes.pp	2011-01-07 13:26:08 UTC (rev 696)
@@ -19,6 +19,7 @@
     include ssh::auth
     include ssh::auth::keymaster
     include buildsystem::mainnode
+    include buildsystem::mgacreatehome
 
     include pam::committers_access
     include restrictshell::allow_svn

Modified: puppet/modules/buildsystem/manifests/init.pp
===================================================================
--- puppet/modules/buildsystem/manifests/init.pp	2011-01-07 02:46:13 UTC (rev 695)
+++ puppet/modules/buildsystem/manifests/init.pp	2011-01-07 13:26:08 UTC (rev 696)
@@ -241,4 +241,16 @@
             content => template("buildsystem/sudoers.iurt")
         }
     }
+
+    # temporary script to create home dir with ssh key
+    # taking login and url as arguments
+    class mgacreatehome {
+	file { "/usr/local/sbin/mgacreatehome":
+            ensure => present,
+            owner => root,
+            group => root,
+            mode => 700,
+            content => template("buildsystem/mgacreatehome")
+	}
+    }
 }

Added: puppet/modules/buildsystem/templates/mgacreatehome
===================================================================
--- puppet/modules/buildsystem/templates/mgacreatehome	                        (rev 0)
+++ puppet/modules/buildsystem/templates/mgacreatehome	2011-01-07 13:26:08 UTC (rev 696)
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+# script to create home directory with ssh key
+# takes two arguments :
+# - login
+# - URL for ssh key
+
+test $# -eq 2 || exit 1
+login="$1"
+sshkeyurl="$2"
+sshkeyfile=`mktemp`
+homeroot='/home'
+
+id "$login" || exit 2
+wget -O "$sshkeyfile" "$sshkeyurl" || exit 2
+cat "$sshkeyfile"
+echo "Press enter to validate"
+read z
+
+test ! -d "$homeroot/$login" && cp -a /etc/skel "$homeroot/$login"
+mkdir "$homeroot/$login/.ssh"
+cat "$sshkeyfile" >> "$homeroot/$login/.ssh/authorized_keys"
+rm -f "$sshkeyfile"
+chmod 700 "$homeroot/$login/.ssh"
+chmod 600 "$homeroot/$login/.ssh/authorized_keys"
+chown -R "$login":mga-users "$homeroot/$login"
+


Property changes on: puppet/modules/buildsystem/templates/mgacreatehome
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20110107/172d58d3/attachment-0001.html>


More information about the Mageia-sysadm mailing list