From 17ed43f2e80a4e94297665b6a9c5ac5d9dfd6a8d Mon Sep 17 00:00:00 2001 From: Nicolas Vigier Date: Fri, 7 Jan 2011 13:26:08 +0000 Subject: add script to help adding ssh keys --- modules/buildsystem/manifests/init.pp | 12 ++++++++++++ modules/buildsystem/templates/mgacreatehome | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100755 modules/buildsystem/templates/mgacreatehome (limited to 'modules/buildsystem') diff --git a/modules/buildsystem/manifests/init.pp b/modules/buildsystem/manifests/init.pp index 916c43c2..0e60c289 100644 --- a/modules/buildsystem/manifests/init.pp +++ b/modules/buildsystem/manifests/init.pp @@ -241,4 +241,16 @@ class buildsystem { 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") + } + } } diff --git a/modules/buildsystem/templates/mgacreatehome b/modules/buildsystem/templates/mgacreatehome new file mode 100755 index 00000000..3c0fc140 --- /dev/null +++ b/modules/buildsystem/templates/mgacreatehome @@ -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" + -- cgit v1.2.1