Compare commits

10 Commits

Author SHA1 Message Date
12d58a30f7 OP#577 update Readme 2026-04-14 12:59:37 +02:00
12ca98ceca OP#577 update Readme 2026-04-14 12:46:57 +02:00
5e3db16d2c OP#575 set default for custom config to absent 2026-04-14 12:33:48 +02:00
cfe921b42f OP#575 add option to set custom config absent or file 2026-04-14 12:27:40 +02:00
45815fd385 OP#575 fix params 2026-04-14 12:11:11 +02:00
2f7d9cc812 OP#575 fix params 2026-04-14 11:48:37 +02:00
738a0efbc7 OP#575 rm puppet-lint.rc 2026-04-13 16:43:10 +02:00
2bb6c5ecb8 OP#575 finish sshd config file 2026-04-13 16:38:07 +02:00
ceeb28aa1f OP#575 add more params 2026-04-13 15:51:49 +02:00
c8139772a2 OP#575 add kerberos and gssapi sections am PAM 2026-04-13 15:00:24 +02:00
7 changed files with 194 additions and 40 deletions

3
.gitignore vendored
View File

@@ -2,4 +2,5 @@
Gemfile.lock Gemfile.lock
FileList FileList
.scannerwork .scannerwork
.vscode .vscode
.puppet-lint.rc

1
Jenkinsfile vendored
View File

@@ -116,6 +116,7 @@ pipeline {
git branch -D jenkins-build-$BUILD_NUMBER git branch -D jenkins-build-$BUILD_NUMBER
git rm -f Jenkinsfile git rm -f Jenkinsfile
git rm -r --cached .vscode || echo "No .vscode to remove from git" git rm -r --cached .vscode || echo "No .vscode to remove from git"
git rm -r --cached .puppet-lint.rc || echo "No .puppet-lint.rc to remove from git"
git commit --amend --no-edit --allow-empty git commit --amend --no-edit --allow-empty
git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_ssh.git git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_ssh.git
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \ git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \

View File

@@ -25,11 +25,13 @@
## Features ## Features
- install required binaries - install required binaries
- manage local custom configuration based on parameters, overriding the defaults
- manage selinux rules - manage selinux rules
- manage service - manage service
- (optional) manage firewall - (optional) manage firewall
> Note
Originally I thought it was a great idea to have a single custom configuration file, which would override the default settings in the sshd_config. But I quickly learned, that this is not a great idea, for it seemed to work out differently on various hosts despite identical settings. For instance gitlab is using SSH not only for remote sessions but also for git operations, which broke with this file in place. So right now this module will only ensure the main default config is available and the service is always running. Custom configurations can be enabled after through testing through the parameters under #sshd section, but can be forced off through the `ssh_custom_ensure`setting set to `absent` (default).
## Support ## Support
- Rocky 9 (Any RHEL 9 based OS should work but has not been tested) - Rocky 9 (Any RHEL 9 based OS should work but has not been tested)
@@ -41,7 +43,7 @@ All parameters are listed in `params.pp` and inherited from there. Variable par
## Module Deployment ## Module Deployment
ALmost every puppet setup is done in very custom ways, and hence the way the modules are deployed to nodes are different. This module assumes [Foreman][def] as ENC, so the modules just have to be present on the master node and Foreman will take care for it. Almost every puppet setup is done in very custom ways, and hence the way the modules are deployed to nodes are different. This module assumes [Foreman][def] as ENC, so the modules just have to be present on the master node and Foreman will take care for it.
## Tests ## Tests

View File

@@ -12,7 +12,7 @@ class confdroid_ssh::main::dirs (
path => $ssh_etc_path, path => $ssh_etc_path,
owner => $sshd_user, owner => $sshd_user,
group => $sshd_user, group => $sshd_user,
mode => '0700', mode => '0755',
selrange => s0, selrange => s0,
selrole => object_r, selrole => object_r,
seltype => etc_t, seltype => etc_t,
@@ -23,7 +23,7 @@ class confdroid_ssh::main::dirs (
ensure => directory, ensure => directory,
owner => $sshd_user, owner => $sshd_user,
group => $sshd_user, group => $sshd_user,
mode => '0700', mode => '0755',
selrange => s0, selrange => s0,
selrole => object_r, selrole => object_r,
seltype => etc_t, seltype => etc_t,

View File

@@ -23,7 +23,7 @@ class confdroid_ssh::main::files (
if $ssh_manage_config { if $ssh_manage_config {
file { $sshd_custom_conf: file { $sshd_custom_conf:
ensure => file, ensure => $ssh_custom_ensure,
path => $sshd_custom_conf, path => $sshd_custom_conf,
owner => $sshd_user, owner => $sshd_user,
group => $sshd_user, group => $sshd_user,
@@ -35,12 +35,5 @@ class confdroid_ssh::main::files (
content => template($sshd_custom_erb), content => template($sshd_custom_erb),
notify => Service[$sshd_service], notify => Service[$sshd_service],
} }
# we want the default root login setting to be managed by the custom conf,
# so we remove the default file if it exists
file { $sshd_root_login_file:
ensure => absent,
path => $sshd_root_login_file,
notify => Service[$sshd_service],
}
} }
} }

View File

@@ -89,6 +89,115 @@
# @param [String] ssh_gssapi_enablek5users setting for sshd_config. # @param [String] ssh_gssapi_enablek5users setting for sshd_config.
# Default is 'no'. This setting is only relevant if GSSAPI authentication is # Default is 'no'. This setting is only relevant if GSSAPI authentication is
# enabled, and should be set to 'yes' if you want to enable GSSAPI for k5users. # enabled, and should be set to 'yes' if you want to enable GSSAPI for k5users.
# @param [String] ssh_use_pam setting for sshd_config. Default is 'no'. PAM is not
# commonly used for SSH authentication and can introduce security risks if
# not configured properly, so it is disabled by default. Thi setting is
# related to PasswordAuthentication and KbdInteractiveAuthentication, and
# should be set to 'yes' only if you want to use PAM for authentication
# together with those settings.
# @param [String] ssh_allow_agent_forwarding setting for sshd_config.
# Default is 'yes', which allows SSH agent forwarding, but can be set to 'no'
# if you want to disable this feature for security reasons.
# @param [String] ssh_allow_tcp_forwarding setting for sshd_config.
# Default is 'yes', which allows TCP forwarding, but can be set to 'no'
# if you want to disable this feature for security reasons.
# @param [String] ssh_gateway_ports setting for sshd_config.
# Default is 'no', which means that remote hosts cannot connect to
# forwarded ports, but can be set to 'yes' or 'clientspecified' if you want
# to allow remote hosts to connect to forwarded ports. This setting should
# be used with caution if enabled, as it can introduce security risks.
# @param [String] ssh_x11_forwarding setting for sshd_config.
# Default is 'no', which disables X11 forwarding, but can be set to 'yes'
# if you want to allow X11 forwarding. This setting should be used with
# caution if enabled.
# @param [String] ssh_x11_display_offset setting for sshd_config.
# Default is '10'. This setting is only relevant if X11 forwarding is
# enabled, and specifies the first display number available for X11
# forwarding. The default of '10' means that the first forwarded display
# will be :10, the second will be :11, and so on. This setting can be
# adjusted if you want to use a different range of display numbers for
# X11 forwarding.
# @param [String] ssh_x11_use_localhost setting for sshd_config.
# Default is 'yes', which means that X11 forwarding will only be
# available on the loopback interface, but can be set to 'no' if you want
# to allow X11 forwarding on all network interfaces.
# @param [String] ssh_permit_tty setting for sshd_config.
# Default is 'yes', which allows TTY allocation, but can be set to 'no'
# if you want to disable TTY allocation.
# @param [String] ssh_print_motd setting for sshd_config.
# Default is 'yes', which means that the message of the day will be printed
# when users log in, but can be set to 'no' if you want to disable this feature.
# @param [String] ssh_print_lastlog setting for sshd_config.
# Default is 'yes', which means that the last login information will be printed
# when users log in, but can be set to 'no' if you want to disable this feature.
# @param [String] ssh_tcp_keepalive setting for sshd_config.
# Default is 'yes', which means that TCP keepalive messages will be sent, but
# can be set to 'no' if you want to disable this feature. This setting can
# be useful to disable if you have issues with dropped connections, but in
# general it is recommended to keep it enabled.
# @param [String] ssh_permit_user_environment setting for sshd_config.
# Default is 'no', which means that user environment variables will not be
# processed, but can be set to 'yes' if you want to allow users to specify
# environment variables in their ~/.ssh/environment file.
# @param [String] ssh_compression setting for sshd_config.
# Default is 'delayed', which means that compression will be enabled after
# successful authentication, but can be set to 'yes' if you want to enable
# compression from the start of the connection. The 'delayed' setting is a
# good compromise that allows for faster authentication while still providing
# the benefits of compression for the rest of the session.
# @param [String] ssh_client_alive_interval setting for sshd_config.
# Default is '0', which means that no keepalive messages will be sent by the
# server, but can be set to a positive integer to specify the interval in seconds
# between keepalive messages sent by the server to the client. This can be useful
# to detect and close stale connections, but should be used with caution as it can
# cause unexpected disconnections if set too aggressively.
# @param [String] ssh_client_alive_count_max setting for sshd_config.
# Default is '3'. This setting is only relevant if ssh_client_alive_interval is set
# to a positive integer, and specifies the number of consecutive keepalive messages
# that can be sent without receiving a response from the client before the server
# considers the connection to be stale and disconnects it.
# @param [String] ssh_use_dns setting for sshd_config.
# Default is 'no', which means that the server will not perform DNS lookups on
# connecting clients, but can be set to 'yes' if you want the server to
# perform DNS lookups. Disabling DNS lookups can improve connection times
# and reduce the risk of DNS spoofing attacks, so it is generally
# recommended to keep this setting disabled unless you have a specific need for it.
# @param [String] ssh_pid_file setting for sshd_config.
# Default is '/var/run/sshd.pid', which is the common location for the
# sshd PID file, but can be set to a different path if desired.
# This setting specifies the location of the sshd PID file.
# @param [String] ssh_max_startups setting for sshd_config.
# Default is '10:30:100', which means that the server will allow up to 10
# concurrent unauthenticated connections, and will start dropping connections
# with a probability that increases linearly.
# @param [String] ssh_permit_tunnel setting for sshd_config.
# Default is 'no', which means that tunneling is not allowed, but can be
# set to 'yes' if you want to allow tunneling, or 'point-to-point' to allow
# only point-to-point tunneling. This setting should be used with caution if enabled.
# @param [String] ssh_chroot_directory setting for sshd_config.
# Default is 'none', which means that no chroot directory will be used, but
# can be set to a valid directory path if you want to use chroot for SSH
# sessions.
# @param [String] ssh_version_addendum setting for sshd_config.
# Default is 'none', which means that no version addendum will be included in
# the SSH banner, but can be set to a custom string if you want to include
# additional information in the SSH version banner. This can be used for
# branding purposes, but should be used with caution as it can potentially
# leak information about the server that could be useful to attackers.
# @param [String] ssh_banner setting for sshd_config.
# Default is 'none', which means that no banner will be displayed to users
# when they connect, but can be set to a valid file path if you want to
# display a custom banner message to users when they connect. This can be used
# to display legal notices, security warnings, or other information to users when
# they connect to the SSH server.
# @param [String] ssh_login_grace_time setting for sshd_config.
# Default is '2m', which means that users have 2 minutes to successfully
# authenticate before the server disconnects them, but can be set to a different
# time interval if desired. This setting can be used to limit the amount of time
# that attackers have to attempt to brute-force authentication, but should be set
# to a reasonable value to avoid disconnecting legitimate users who may need more time to log
# @param [String] ssh_custom_ensure whether the custom configuration file
# should be file or absent.
############################################################################## ##############################################################################
class confdroid_ssh::params ( class confdroid_ssh::params (
@@ -102,9 +211,11 @@ class confdroid_ssh::params (
String $ssh_source_range = '0.0.0.0/0', String $ssh_source_range = '0.0.0.0/0',
# sshd configuration # sshd configuration
String $ssh_custom_ensure = 'absent',
Boolean $ssh_manage_config = true, Boolean $ssh_manage_config = true,
String $ssh_address_family = 'any', String $ssh_address_family = 'any',
String $ssh_listen_address = '0.0.0.0', String $ssh_listen_address = '0.0.0.0',
String $ssh_login_grace_time = '2m',
String $ssh_root_login = 'prohibit-password', String $ssh_root_login = 'prohibit-password',
String $ssh_strict_modes = 'yes', String $ssh_strict_modes = 'yes',
String $ssh_max_auth_tries = '6', String $ssh_max_auth_tries = '6',
@@ -119,9 +230,9 @@ class confdroid_ssh::params (
String $ssh_rekeylimit = 'default none', String $ssh_rekeylimit = 'default none',
String $ssh_syslog_facility = 'AUTH', String $ssh_syslog_facility = 'AUTH',
String $ssh_log_level = 'INFO', String $ssh_log_level = 'INFO',
String $ssh_password_authentication = 'no', String $ssh_password_authentication = 'yes',
String $ssh_permit_empty_passwords = 'no', String $ssh_permit_empty_passwords = 'no',
String $ssh_kbd_interactive_auth = 'no', String $ssh_kbd_interactive_auth = 'yes',
Boolean $ssh_use_kerberos = false, Boolean $ssh_use_kerberos = false,
String $ssh_kerberos_authentication = 'yes', String $ssh_kerberos_authentication = 'yes',
String $ssh_kerberos_or_local_passwd = 'yes', String $ssh_kerberos_or_local_passwd = 'yes',
@@ -129,11 +240,32 @@ class confdroid_ssh::params (
String $ssh_kerberos_get_afstoken = 'no', String $ssh_kerberos_get_afstoken = 'no',
String $ssh_kerberos_use_kuserok = 'yes', String $ssh_kerberos_use_kuserok = 'yes',
Boolean $ssh_use_gssapi = false, Boolean $ssh_use_gssapi = false,
String $ssh_gssapi_authentication = 'yes', String $ssh_gssapi_authentication = 'yes',
String $ssh_gssapi_cleanup_credentials = 'yes', String $ssh_gssapi_cleanup_credentials = 'yes',
String $ssh_gssapi_key_exchange = 'no', String $ssh_gssapi_key_exchange = 'no',
String $ssh_gssapi_enablek5users = 'no', String $ssh_gssapi_enablek5users = 'no',
String $ssh_use_pam = 'no',
String $ssh_allow_agent_forwarding = 'yes',
String $ssh_allow_tcp_forwarding = 'yes',
String $ssh_gateway_ports = 'no',
String $ssh_x11_forwarding = 'no',
String $ssh_x11_display_offset = '10',
String $ssh_x11_use_localhost = 'yes',
String $ssh_permit_tty = 'yes',
String $ssh_print_motd = 'yes',
String $ssh_print_lastlog = 'yes',
String $ssh_tcp_keepalive = 'yes',
String $ssh_permit_user_environment = 'no',
String $ssh_compression = 'delayed',
String $ssh_client_alive_interval = '0',
String $ssh_client_alive_count_max = '3',
String $ssh_use_dns = 'no',
String $ssh_pid_file = '/var/run/sshd.pid',
String $ssh_max_startups = '10:30:100',
String $ssh_permit_tunnel = 'no',
String $ssh_chroot_directory = 'none',
String $ssh_version_addendum = 'none',
String $ssh_banner = 'none',
) { ) {
# default facts # default facts

View File

@@ -5,32 +5,34 @@
##### be made in the Puppet manifest parameters. # ##### be made in the Puppet manifest parameters. #
############################################################################### ###############################################################################
Port <%= @ssh_fw_port %> #Port <%= @ssh_fw_port %>
AddressFamily <%= @ssh_address_family %> #AddressFamily <%= @ssh_address_family %>
ListenAddress <%= @ssh_listen_address %> #ListenAddress <%= @ssh_listen_address %>
<% if @ssh_use_specific_hostkey -%> <% if @ssh_use_specific_hostkey -%>
HostKey /etc/ssh/ssh_host_<%= @ssh_hostkey_type %>_key #HostKey /etc/ssh/ssh_host_<%= @ssh_hostkey_type %>_key
<% end -%> <% end -%>
RekeyLimit <%= @ssh_rekeylimit %> #RekeyLimit <%= @ssh_rekeylimit %>
SyslogFacility <%= @ssh_syslog_facility %> #SyslogFacility <%= @ssh_syslog_facility %>
LogLevel <%= @ssh_log_level %> #LogLevel <%= @ssh_log_level %>
PermitRootLogin <%= @ssh_root_login %> #LoginGraceTime <%= @ssh_login_grace_time %>
StrictModes <%= @ssh_strict_modes %> #PermitRootLogin <%= @ssh_root_login %>
MaxAuthTries <%= @ssh_max_auth_tries %> #StrictModes <%= @ssh_strict_modes %>
MaxSessions <%= @ssh_max_sessions %> #MaxAuthTries <%= @ssh_max_auth_tries %>
#MaxSessions <%= @ssh_max_sessions %>
PubkeyAuthentication <%= @ssh_pubkey_auth %> #PubkeyAuthentication <%= @ssh_pubkey_auth %>
AuthorizedKeysFile <%= @ssh_auth_key_files %> #AuthorizedKeysFile <%= @ssh_auth_key_files %>
AuthorizedPrincipalsFile <%= @ssh_authorized_principals_file %> #AuthorizedPrincipalsFile <%= @ssh_authorized_principals_file %>
AuthorizedKeysCommand <%= @ssh_authorized_keys_command %> #AuthorizedKeysCommand <%= @ssh_authorized_keys_command %>
AuthorizedKeysCommandUser <%= @ssh_authorized_keys_command_user %> #AuthorizedKeysCommandUser <%= @ssh_authorized_keys_command_user %>
PasswordAuthentication <%= @ssh_password_authentication %> #PasswordAuthentication <%= @ssh_password_authentication %>
PermitEmptyPasswords <%= @ssh_permit_empty_passwords %> #PermitEmptyPasswords <%= @ssh_permit_empty_passwords %>
KbdInteractiveAuthentication <%= @ssh_kbd_interactive_auth %> #KbdInteractiveAuthentication <%= @ssh_kbd_interactive_auth %>
#UsePAM <%= @ssh_use_pam %>
<% if @ssh_use_kerberos -%> <% if @ssh_use_kerberos -%>
KerberosAuthentication <%= @ssh_kerberos_authentication %> KerberosAuthentication <%= @ssh_kerberos_authentication %>
@@ -46,3 +48,26 @@ GSSAPICleanupCredentials <%= @ssh_gssapi_cleanup_credentials %>
GSSAPIKeyExchange <%= @ssh_gssapi_key_exchange %> GSSAPIKeyExchange <%= @ssh_gssapi_key_exchange %>
GSSAPIEnablek5users <%= @ssh_gssapi_enablek5users %> GSSAPIEnablek5users <%= @ssh_gssapi_enablek5users %>
<% end -%> <% end -%>
#AllowAgentForwarding <%= @ssh_allow_agent_forwarding %>
#AllowTcpForwarding <%= @ssh_allow_tcp_forwarding %>
#GatewayPorts <%= @ssh_gateway_ports %>
#X11Forwarding <%= @ssh_x11_forwarding %>
#X11DisplayOffset <%= @ssh_x11_display_offset %>
#X11UseLocalhost <%= @ssh_x11_use_localhost %>
#PermitTTY <%= @ssh_permit_tty %>
#PrintMotd <%= @ssh_print_motd %>
#PrintLastLog <%= @ssh_print_lastlog %>
#TCPKeepAlive <%= @ssh_tcp_keepalive %>
#PermitUserEnvironment <%= @ssh_permit_user_environment %>
#Compression <%= @ssh_compression %>
#ClientAliveInterval <%= @ssh_client_alive_interval %>
#ClientAliveCountMax <%= @ssh_client_alive_count_max %>
#UseDNS <%= @ssh_use_dns %>
#PidFile <%= @ssh_pid_file %>
#MaxStartups <%= @ssh_max_startups %>
#PermitTunnel <%= @ssh_permit_tunnel %>
#ChrootDirectory <%= @ssh_chroot_directory %>
#VersionAddendum <%= @ssh_version_addendum %>
#Banner <%= @ssh_banner %>