|
- {%- set sshd_config = pillar.get('sshd_config', {}) -%}
- {
- {%- set processed_options = [] -%}
-
- {
- {
- {%- macro render_option(keyword, default, config_dict=sshd_config) -%}
- {%- set value = config_dict.get(keyword, default) -%}
- {%- if value is sameas true -%}
- {{ keyword }} yes
- {%- elif value is sameas false -%}
- {{ keyword }} no
- {%- elif value is string or value is number -%}
- {{ keyword }} {{ value }}
- {%- else -%}
- {%- for single_value in value -%}
- {{ keyword }} {{ single_value }}
- {% endfor -%}
- {%- endif -%}
- {%- endmacro -%}
-
- {
- {%- macro option_impl(keyword, default, present) -%}
- {%- if present -%}
- {%- do processed_options.append(keyword) -%}
- {%- set prefix='' -%}
- {%- else -%}
- {%- set prefix='#' -%}
- {%- endif -%}
- {
- {%- set keyword = prefix ~ keyword -%}
- {{ render_option(keyword, default) }}
- {%- endmacro -%}
-
- {
- {%- macro option(keyword, default, present) -%}
- {{ option_impl(keyword, default, keyword in sshd_config) }}
- {%- endmacro -%}
-
- {
- {%- macro option_default_uncommented(keyword, default, present) -%}
- {{ option_impl(keyword, default, True) }}
- {%- endmacro -%}
-
-
-
-
-
-
-
- {{ option('Port', 22) }}
-
- {{ option('ListenAddress', ['::', '0.0.0.0']) }}
- {{ option_default_uncommented('Protocol', 2) }}
-
-
- {{ option_default_uncommented('HostKey', ['/etc/ssh/ssh_host_rsa_key', '/etc/ssh/ssh_host_dsa_key', '/etc/ssh/ssh_host_ecdsa_key', '/etc/ssh/ssh_host_ed25519_key']) -}}
-
-
- {{ option_default_uncommented('UsePrivilegeSeparation', 'yes') }}
-
-
- {{ option_default_uncommented('KeyRegenerationInterval', 3600) }}
- {{ option_default_uncommented('ServerKeyBits', 768) }}
-
-
- {{ option_default_uncommented('SyslogFacility', 'AUTH') }}
- {{ option_default_uncommented('LogLevel', 'INFO') }}
-
-
- {{ option_default_uncommented('LoginGraceTime', 120) }}
- {{ option_default_uncommented('PermitRootLogin', 'no') }}
- {{ option_default_uncommented('StrictModes', 'yes') }}
-
- {{ option('DSAAuthentication', 'yes') }}
- {{ option_default_uncommented('RSAAuthentication', 'yes') }}
- {{ option_default_uncommented('PubkeyAuthentication', 'yes') }}
- {{ option('AuthorizedKeysFile', '%h/.ssh/authorized_keys') }}
-
-
- {{ option_default_uncommented('IgnoreRhosts', 'yes') }}
-
- {{ option_default_uncommented('RhostsRSAAuthentication', 'no') }}
-
- {{ option_default_uncommented('HostbasedAuthentication', 'no') }}
-
- {{ option('IgnoreUserKnownHosts', 'yes') }}
-
-
- {{ option_default_uncommented('PermitEmptyPasswords', 'no') }}
-
-
-
- {{ option_default_uncommented('ChallengeResponseAuthentication', 'no') }}
- {{ option('AuthenticationMethods', 'publickey,keyboard-interactive') }}
-
-
- {{ option('PasswordAuthentication', 'yes') }}
-
-
- {{ option('KerberosAuthentication', 'no') }}
- {{ option('KerberosGetAFSToken', 'no') }}
- {{ option('KerberosOrLocalPasswd', 'yes') }}
- {{ option('KerberosTicketCleanup', 'yes') }}
-
-
- {{ option('GSSAPIAuthentication', 'no') }}
- {{ option('GSSAPICleanupCredentials', 'yes') }}
-
- {{ option_default_uncommented('X11Forwarding', 'yes') }}
- {{ option('AllowTcpForwarding', 'yes') }}
- {{ option_default_uncommented('X11DisplayOffset', '10') }}
- {{ option_default_uncommented('PrintMotd', 'no') }}
- {{ option_default_uncommented('PrintLastLog', 'yes') }}
- {{ option_default_uncommented('TCPKeepAlive', 'yes') }}
- {{ option('UseLogin', 'no') }}
-
- {{ option('MaxStartups', '10:30:60') }}
- {{ option('Banner', '/etc/issue.net') }}
-
-
- {{ option_default_uncommented('AcceptEnv', 'LANG LC_*') }}
-
- {{ option_default_uncommented('Subsystem', 'sftp /usr/lib/openssh/sftp-server') }}
-
-
-
-
-
-
-
-
-
-
- {{ option_default_uncommented('UsePAM', 'yes') }}
-
-
- {{ option('UseDNS', 'yes') }}
-
-
-
-
-
-
-
-
-
-
-
-
- {{ option('DenyUsers', '') }}
-
- {{ option('AllowUsers', '') }}
-
- {{ option('DenyGroups', '') }}
-
- {{ option('AllowGroups', '') }}
-
-
- {{ option('KexAlgorithms', 'ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1') }}
-
-
- {{ option('Ciphers', 'aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,rijndael-cbc@lysator.liu.se') }}
-
-
- {{ option('MACs', 'hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96') }}
-
- {
- {%- for keyword in sshd_config.keys() %}
- {
- {%- if not keyword in processed_options and keyword != 'matches' -%}
- {
- {{ render_option(keyword, '') }}
- {%- endif -%}
- {%- endfor %}
-
- {
- {%- if 'matches' in sshd_config %}
- {%- for match in sshd_config['matches'].values() %}
- Match {{ match['type'].keys()[0] }} {{ match['type'].values()[0] }}
- {%- for keyword in match['options'].keys() %}
- {{ render_option(keyword, '', config_dict=match['options']) }}
- {%- endfor %}
- {%- endfor %}
- {%- endif %}
|