SSH - moduli


Ssh - Asentaa ssh-clientin ja ssh-serverin. Ylläpitää ssh-serveriä.


Ladattavissa täältä.

Käyttöjärjestelmät:

Testattu seuraavilla käyttöjärjestelmillä:


Xubuntu 12.10 32-bit

Ubuntu 12.04 LTS 64-bit

Debian 6.0 64-bit


Rakenne:

ssh
├── manifests
│   ├── config.pp
│   ├── init.pp
│   ├── install.pp
│   ├── params.pp
│   └── service.pp
├── README
└── templates
    └── sshd_config.erb

README

######################
# Puppet module: ssh #
######################

This module openssh-client and openssh-server.
It also manages '/etc/ssh/sshd_config' and openssh-server.

######################
# TODO before using  #
######################

Check ssh::params for wanted specifications.

################
# Sample usage #
################

include ssh

##########
# Author #
##########

Made by Sampo Tyllilä <sampo.tyllila@gmail.com>

###########
# License #
###########

This software is distributed under the GNU General Public License version 2 or any later version.
http://www.gnu.org/licenses/

Manifests kansion sisältö:


init.pp

# == Class: ssh
#
# This module manages ssh-server.
#
# === Parameters
#
# [*package*] - The name of the package to install.
# [*service*] - The name of the managed service.
# [*port*]    - The port to listen.
#
# === Examples
#
# See README for details.
#
# === Author
#
# Sampo Tyllilä 
#
class ssh (
        $package = $ssh::params::package,
        $service = $ssh::params::service,
        $port    = $ssh::params::port
)       inherits ssh::params {

        include ssh::params, ssh::install, ssh::service, ssh::config

}

install.pp

# == Class: ssh::install
#
# This module installs ssh-client and ssh-server.
#
# === Parameters
#
# [*package*] - The name of the package to install.
#
# === Author
#
# Sampo Tyllilä 
#
class ssh::install {
        package { $package:
                ensure     => latest,
        }
}

service.pp

# == Class: ssh::service
#
# This class manages ssh-server service.
#
# === Parameters
#
# [*service*] - The name of the managed service.
#
# === Requires
#
# The ssh::install class.
#
# === Author
#
# Sampo Tyllilä 
#
class ssh::service {
        service { $service:
                ensure    => running,
                enable    => true,
                hasstatus => false,
                status    => 'sshd',
                require   => Class['ssh::install'],
        }
}

config.pp

# == Class: ssh::config
#
# This class manages '/etc/ssh/sshd_config'.
#
# === Parameters
#
# No parameters in this class.
#
# === Requires
#
# The ssh::install class.
#
# === Notifies
#
# The ssh::service class.
#
# === Author
#
# Sampo Tyllilä 
#
class ssh::config {
        file { '/etc/ssh/sshd_config':
                ensure  => present,
                owner   => 'root',
                group   => 'root',
                mode    => '0600',
                content => template('ssh/sshd_config.erb'),
                require => Class['ssh::install'],
                notify  => Class['ssh::service'],
        }
}

params.pp

# == Class: ssh::params
#
# This class manages the parameters of this ssh module.
#
# === Parameters
#
# [*package*] - The name of the package to install.
# [*service*] - The name of the managed service.
# [*port*]    - The port to listen.
#
# === Author
#
# Sampo Tyllilä 
#
class ssh::params {
        $port    = '22'
        $service = 'ssh'
        $package = ['openssh-client', 'openssh-server']
}

Templates kansion sisältö:


sshd_config.erb

# MANAGED BY PUPPET!
#
# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port <%= port %>
# 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 yes
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 yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#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

Huomioita.

Moduli on vielä hyvin yksinkertainen, mutta lisäämällä parametreja vaikuttamaan 'sshd_config'-tiedostoon saisimme hieman enemmän monipuolisuutta.