Puppet Class: profile::ssh::server

Defined in:
modules/profile/manifests/ssh/server.pp

Summary

manage the ssh server daemon and config

Overview

SPDX-License-Identifier: Apache-2.0

Parameters:

  • listen_ports (Array[Stdlib::Port]) (defaults to: lookup('profile::ssh::server::listen_ports'))

    the ports to listen on

  • listen_addresses (Array[Stdlib::IP::Address]) (defaults to: lookup('profile::ssh::server::listen_addresses'))

    an array of addresses to listen on

  • permit_root (Ssh::Config::PermitRootLogin) (defaults to: lookup('profile::ssh::server::permit_root'))

    if true allow root logins

  • authorized_keys_file (Array[Stdlib::Unixpath]) (defaults to: lookup('profile::ssh::server::authorized_keys_file'))

    space seperated list of authorized keys files

  • lookup_keys_from_ldap (Boolean) (defaults to: lookup('profile::ssh::server::lookup_keys_from_ldap'))

    if true, user keys will be looked up from ldap

  • disable_nist_kex (Boolean) (defaults to: lookup('profile::ssh::server::disable_nist_kex'))

    Allow uses to temporarily opt out of nist kex disabling

  • explicit_macs (Boolean) (defaults to: lookup('profile::ssh::server::explicit_macs'))

    Allow users to opt out of more secure MACs

  • enable_hba (Boolean) (defaults to: lookup('profile::ssh::server::enable_hba'))

    enable host based authentication

  • enable_kerberos (Boolean) (defaults to: lookup('profile::ssh::server::enable_kerberos'))

    enable kerberos

  • disable_agent_forwarding (Boolean) (defaults to: lookup('profile::ssh::server::disable_agent_forwarding'))

    disable agent forwarding

  • max_sessions (Optional[Integer]) (defaults to: lookup('profile::ssh::server::max_sessions'))

    allow users to override the maximum number ops sessions

  • max_startups (Optional[String[1]]) (defaults to: lookup('profile::ssh::server::max_startups'))

    allow users to override the maximum number ops startups

  • gateway_ports (Boolean) (defaults to: lookup('profile::ssh::server::gateway_ports'))

    if true set sshd_config GatewayPorts to yes

  • accept_env (Array[String[1]]) (defaults to: lookup('profile::ssh::server::accept_env'))

    array of elements for AcceptEnv config

  • match_config (Array[Ssh::Match]) (defaults to: lookup('profile::ssh::server::match_config'))

    a list of additional configs to apply to specific matches. see Ssh::Match for the data structure

  • enabled_key_types (Array[Ssh::KeyType]) (defaults to: lookup('profile::ssh::server::enabled_key_types'))

    server key types to enable, if not provided via $host_keys

  • puppetserver_ca_host_certs (Boolean) (defaults to: lookup('profile::ssh::server::puppetserver_ca_host_certs'))

    if true, puppetserver ca signed host certs will be made available

  • trusted_user_ca_keys (Array[String[1]]) (defaults to: lookup('profile::ssh::server::trusted_user_ca_keys', { 'default_value' => [] }))

    array of trusted user ca keys

  • host_keys (Ssh::HostKeys) (defaults to: lookup('profile::ssh::server::host_keys', { 'default_value' => {} }))

    array of ssh host key structs

  • host_certs (Ssh::HostCerts) (defaults to: lookup('profile::ssh::server::host_certs', { 'default_value' => {} }))

    array of ssh host cert structs

  • authorized_principals_file (Optional[Stdlib::Unixpath]) (defaults to: lookup('profile::ssh::server::authorized_principals_file', { 'default_value' => undef }))

    path name to file

  • authorized_principals (Array[String[1]]) (defaults to: lookup('profile::ssh::server::authorized_principals', { 'default_value' => [] }))

    array of global principals



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'modules/profile/manifests/ssh/server.pp', line 26

class profile::ssh::server (
    Array[Stdlib::Port]          $listen_ports               = lookup('profile::ssh::server::listen_ports'),
    Array[Stdlib::IP::Address]   $listen_addresses           = lookup('profile::ssh::server::listen_addresses'),
    Ssh::Config::PermitRootLogin $permit_root                = lookup('profile::ssh::server::permit_root'),
    Array[Stdlib::Unixpath]      $authorized_keys_file       = lookup('profile::ssh::server::authorized_keys_file'),
    Boolean                      $lookup_keys_from_ldap      = lookup('profile::ssh::server::lookup_keys_from_ldap'),
    Boolean                      $disable_nist_kex           = lookup('profile::ssh::server::disable_nist_kex'),
    Boolean                      $explicit_macs              = lookup('profile::ssh::server::explicit_macs'),
    Boolean                      $enable_hba                 = lookup('profile::ssh::server::enable_hba'),
    Boolean                      $enable_kerberos            = lookup('profile::ssh::server::enable_kerberos'),
    Boolean                      $disable_agent_forwarding   = lookup('profile::ssh::server::disable_agent_forwarding'),
    Optional[Integer]            $max_sessions               = lookup('profile::ssh::server::max_sessions'),
    Optional[String[1]]          $max_startups               = lookup('profile::ssh::server::max_startups'),
    Boolean                      $gateway_ports              = lookup('profile::ssh::server::gateway_ports'),
    Array[String[1]]             $accept_env                 = lookup('profile::ssh::server::accept_env'),
    Array[Ssh::Match]            $match_config               = lookup('profile::ssh::server::match_config'),
    Array[Ssh::KeyType]          $enabled_key_types          = lookup('profile::ssh::server::enabled_key_types'),
    Boolean                      $puppetserver_ca_host_certs = lookup('profile::ssh::server::puppetserver_ca_host_certs'),
    Array[String[1]]             $trusted_user_ca_keys       = lookup('profile::ssh::server::trusted_user_ca_keys', { 'default_value' => [] }),
    Ssh::HostKeys                $host_keys                  = lookup('profile::ssh::server::host_keys', { 'default_value' => {} }),
    Ssh::HostCerts               $host_certs                 = lookup('profile::ssh::server::host_certs', { 'default_value' => {} }),
    Optional[Stdlib::Unixpath]   $authorized_principals_file = lookup('profile::ssh::server::authorized_principals_file', { 'default_value' => undef }),
    Array[String[1]]             $authorized_principals      = lookup('profile::ssh::server::authorized_principals', { 'default_value' => [] }),
) {
    if $lookup_keys_from_ldap {
        ensure_packages(['python3-ldap'])

        # The 'ssh-key-ldap-lookup' tool is called during login ssh via AuthorizedKeysCommand.  It
        #  returns public keys from ldap for the specified username.
        # It is in /usr/sbin and not /usr/local/sbin because on Debian /usr/local is 0775
        # and sshd refuses to use anything under /usr/local because of the permissive group
        # permission there (and group is set to 'staff', slightly different from root).
        # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=538392
        file { '/usr/sbin/ssh-key-ldap-lookup':
            owner  => 'root',
            group  => 'root',
            mode   => '0555',
            source => 'puppet:///modules/profile/ssh/server/ssh-key-ldap-lookup.py',
        }

        # For security purposes, sshd will only run ssh-key-ldap-lookup as the 'ssh-key-ldap-lookup' user.
        user { 'ssh-key-ldap-lookup':
            ensure => present,
            system => true,
            home   => '/nonexistent', # Since things seem to check for $HOME/.whatever unconditionally...
            shell  => '/bin/false',
        }

        $authorized_keys_command = '/usr/sbin/ssh-key-ldap-lookup'
        $authorized_keys_command_user = 'ssh-key-ldap-lookup'
    } else {
        $authorized_keys_command = undef
        $authorized_keys_command_user = undef
    }

    if length($authorized_principals) > 0 and $authorized_principals_file {
        file { $authorized_principals_file :
            ensure  => file,
            owner   => 'root',
            group   => 'root',
            mode    => '0444',
            content => "${join($authorized_principals, "\n")}\n",
        }
    }

    class {'ssh::server':
        *                            => wmflib::resource::filter_params(
                                          'lookup_keys_from_ldap',
                                          'authorized_principals'
                                        ),
        authorized_keys_command      => $authorized_keys_command,
        authorized_keys_command_user => $authorized_keys_command_user,
    }
}