From 5f4a14a42c3169e69aa0f4675ea530a499229ca6 Mon Sep 17 00:00:00 2001 From: karim hamidou Date: Tue, 24 Dec 2013 15:52:49 +0100 Subject: [PATCH] added puppet module for sshd --- bootstrap.rb | 12 ++- manifests/default.pp | 2 +- manifests/server.pp | 14 ++- puppet_modules/sshd/manifests/init.pp | 24 +++++ puppet_modules/sshd/templates/sshd_config.erb | 88 +++++++++++++++++++ 5 files changed, 136 insertions(+), 4 deletions(-) create mode 100644 puppet_modules/sshd/manifests/init.pp create mode 100644 puppet_modules/sshd/templates/sshd_config.erb diff --git a/bootstrap.rb b/bootstrap.rb index a451989..ea8548a 100644 --- a/bootstrap.rb +++ b/bootstrap.rb @@ -28,6 +28,16 @@ printf "Getting the sources from #{srcrepo} " `ssh root@#{hostname} bash -c "\ apt-get update;\ apt-get install -y git puppet;\ -git clone #{srcrepo} /root/kite;"` +if [ ! -d /root/kite ]; then\ + git clone #{srcrepo} /root/kite;\ +else\ + cd /root/kite; git pull;\ +fi +"` puts "OK" + +puts "Applying Puppet configuration " +`ssh root@#{hostname} bash -c "\ + puppet apply /root/kite/manifests/server.pp --modulepath=/root/kite/puppet_modules/\"` +puts "OK" diff --git a/manifests/default.pp b/manifests/default.pp index a59384d..ae7d262 100644 --- a/manifests/default.pp +++ b/manifests/default.pp @@ -6,7 +6,7 @@ exec {"apt-get update": path => ["/usr/bin/", "/usr/sbin"], } -$packages = ["python", "python-pip", "bpython", +$packages = ["python", "python-pip", "bpython", "fail2ban", "mutt", "python-pyinotify", "mailutils"] $python_packages = ["python-dateutil"] diff --git a/manifests/server.pp b/manifests/server.pp index 2a18b81..c415381 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -1,5 +1,15 @@ # Puppet manifest for setting up kite on a server - import "settings.pp" import "default.pp" -import "puppetlabs/vcsrepo" + +file {'/home/kite/app': + ensure => 'directory', + require => User['kite'], + source => "/root/kite/src", + recurse => true, + owner => 'kite', +} + +class {'sshd': + +} diff --git a/puppet_modules/sshd/manifests/init.pp b/puppet_modules/sshd/manifests/init.pp new file mode 100644 index 0000000..8811468 --- /dev/null +++ b/puppet_modules/sshd/manifests/init.pp @@ -0,0 +1,24 @@ +# a class for installing and configuring a basic nginx setup + +class sshd ($server_name) { + $packages = ["openssh-server"] + + package { $packages: + ensure => present, + } + + file {"/etc/ssh/sshd_config": + owner => "root", + group => "root", + content => template('sshd/sshd_config.erb') + notify => Service['ssh'] + } + + service {'ssh': + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + require => Package["openssh-server"] + } +} diff --git a/puppet_modules/sshd/templates/sshd_config.erb b/puppet_modules/sshd/templates/sshd_config.erb new file mode 100644 index 0000000..5a670d0 --- /dev/null +++ b/puppet_modules/sshd/templates/sshd_config.erb @@ -0,0 +1,88 @@ +# Package generated configuration file +# See the sshd_config(5) manpage for details + +# What ports, IPs and protocols we listen for +Port 22 +# Use these options to restrict which interfaces/protocols sshd will bind to +#ListenAddress :: +#ListenAddress 0.0.0.0 +Protocol 2 +# HostKeys for protocol version 2 +HostKey /etc/ssh/ssh_host_rsa_key +HostKey /etc/ssh/ssh_host_dsa_key +HostKey /etc/ssh/ssh_host_ecdsa_key +#Privilege Separation is turned on for security +UsePrivilegeSeparation yes + +# Lifetime and size of ephemeral version 1 server key +KeyRegenerationInterval 3600 +ServerKeyBits 768 + +# Logging +SyslogFacility AUTH +LogLevel INFO + +# Authentication: +LoginGraceTime 120 +PermitRootLogin no +StrictModes yes + +RSAAuthentication yes +PubkeyAuthentication yes +#AuthorizedKeysFile %h/.ssh/authorized_keys + +# Don't read the user's ~/.rhosts and ~/.shosts files +IgnoreRhosts yes +# For this to work you will also need host keys in /etc/ssh_known_hosts +RhostsRSAAuthentication no +# similar for protocol version 2 +HostbasedAuthentication no +# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication +#IgnoreUserKnownHosts yes + +# To enable empty passwords, change to yes (NOT RECOMMENDED) +PermitEmptyPasswords no + +# Change to yes to enable challenge-response passwords (beware issues with +# some PAM modules and threads) +ChallengeResponseAuthentication no + +# Change to no to disable tunnelled clear text passwords +PasswordAuthentication no + +# Kerberos options +#KerberosAuthentication no +#KerberosGetAFSToken no +#KerberosOrLocalPasswd yes +#KerberosTicketCleanup yes + +# GSSAPI options +#GSSAPIAuthentication no +#GSSAPICleanupCredentials yes + +X11Forwarding no +X11DisplayOffset 10 +PrintMotd no +PrintLastLog yes +TCPKeepAlive yes +#UseLogin no + +MaxStartups 4:10:12 +#Banner /etc/issue.net + +# Allow client to pass locale environment variables +AcceptEnv LANG LC_* + +Subsystem sftp /usr/lib/openssh/sftp-server + +# Set this to 'yes' to enable PAM authentication, account processing, +# and session processing. If this is enabled, PAM authentication will +# be allowed through the ChallengeResponseAuthentication and +# PasswordAuthentication. Depending on your PAM configuration, +# PAM authentication via ChallengeResponseAuthentication may bypass +# the setting of "PermitRootLogin without-password". +# If you just want the PAM account and session checks to run without +# PAM authentication, then enable this but set PasswordAuthentication +# and ChallengeResponseAuthentication to 'no'. +UsePAM yes + -- 2.43.0