create portforwarder key
authorPeter Palfrader <peter@palfrader.org>
Thu, 20 Aug 2015 07:15:26 +0000 (09:15 +0200)
committerPeter Palfrader <peter@palfrader.org>
Thu, 20 Aug 2015 07:15:26 +0000 (09:15 +0200)
modules/portforwarder/manifests/init.pp

index 2cc4582..e7009b2 100644 (file)
@@ -1,6 +1,14 @@
 class portforwarder {
        # do not depend on xinetd, yet.  it might uninstall other inetds
        # for now this will have to be done manually
+
+       if ! $::portforwarder_key {
+               exec { 'create-portforwarder-key':
+                       command => '/bin/su - portforwarder -c \'mkdir -p -m 02700 .ssh && ssh-keygen -C "`whoami`@`hostname` (`date +%Y-%m-%d`)" -P "" -f .ssh/id_rsa -q\'',
+                       onlyif  => '/usr/bin/getent passwd portforwarder > /dev/null && ! [ -e /home/portforwarder/.ssh/id_rsa ]'
+               }
+       }
+
        file { '/etc/ssh/userkeys/portforwarder':
                content => template('portforwarder/authorized_keys.erb'),
        }