OP#561 add root login

This commit is contained in:
2026-04-05 16:11:17 +02:00
parent ff0bacd593
commit 05800c2a21
3 changed files with 21 additions and 9 deletions

View File

@@ -35,5 +35,12 @@ 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

@@ -11,6 +11,7 @@
# @param [Boolean] ssh_manage_config whether to manage the configuration # @param [Boolean] ssh_manage_config whether to manage the configuration
# @param [String] ssh_address_family AddressFamily setting for sshd_config # @param [String] ssh_address_family AddressFamily setting for sshd_config
# @param [String] ssh_listen_address ListenAddress setting for sshd_config # @param [String] ssh_listen_address ListenAddress setting for sshd_config
# @param [String] ssh_root_login PermitRootLogin setting for sshd_config
############################################################################## ##############################################################################
class confdroid_ssh::params ( class confdroid_ssh::params (
@@ -27,6 +28,7 @@ class confdroid_ssh::params (
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_root_login = 'prohibit-password',
) { ) {
# default facts # default facts
@@ -36,14 +38,15 @@ class confdroid_ssh::params (
$os_name = $facts['os']['name'] $os_name = $facts['os']['name']
$os_release = $facts['os']['release']['major'] $os_release = $facts['os']['release']['major']
$sshd_user = 'root' $sshd_user = 'root'
$ssh_etc_path = '/etc/ssh' $ssh_etc_path = '/etc/ssh'
$sshd_service = 'sshd' $sshd_service = 'sshd'
$sshd_config_path = "${ssh_etc_path}/sshd_config" $sshd_config_path = "${ssh_etc_path}/sshd_config"
$sshd_custom_path = "${ssh_etc_path}/sshd_config.d" $sshd_custom_path = "${ssh_etc_path}/sshd_config.d"
$sshd_custom_conf = "${sshd_custom_path}/10-custom.conf" $sshd_custom_conf = "${sshd_custom_path}/10-custom.conf"
$sshd_custom_erb = 'confdroid_ssh/sshd_custom_conf.erb' $sshd_custom_erb = 'confdroid_ssh/sshd_custom_conf.erb'
$sshd_config_erb = 'confdroid_ssh/sshd_config.erb' $sshd_config_erb = 'confdroid_ssh/sshd_config.erb'
$sshd_root_login_file = "${sshd_custom_path}/01-permitrootlogin.conf"
# includes must be last # includes must be last
include confdroid_ssh::main::config include confdroid_ssh::main::config

View File

@@ -7,4 +7,6 @@
Port <%= @ssh_fw_port %> Port <%= @ssh_fw_port %>
AddressFamily <%= @ssh_address_family %> AddressFamily <%= @ssh_address_family %>
ListenAddress <%= @ssh_listen_address %> ListenAddress <%= @ssh_listen_address %>
PermitRootLogin <%= @ssh_root_login %>