Puppet Class: profile::ssh::server
- Defined in:
- modules/profile/manifests/ssh/server.pp
Summary
manage the ssh server daemon and configOverview
SPDX-License-Identifier: Apache-2.0
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,
}
}
|