blob: 3e6ae5c41ae8c393adfedf241e7fd336f59855b4 [file] [log] [blame]
{%- from "openssh/map.jinja" import server with context %}
# Package generated configuration file
# See the sshd_config(5) manpage for details
{%- if server.binds is defined %}
{%- for bind in server.binds %}
ListenAddress {{ bind.address|default("0.0.0.0") }}:{{ bind.port|default("22") }}
{%- endfor %}
{%- else %}
# What ports, IPs and protocols we listen for
Port {{ server.bind.port }}
# Use these options to restrict which interfaces/protocols sshd will bind to
ListenAddress {{ server.bind.address }}
{%- endif %}
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
{%- if grains.os_family != 'CentOS' %}
HostKey /etc/ssh/ssh_host_ecdsa_key
{%- endif %}
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits {{ server.get('server_key_bits', '2048') }}
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin {% if server.get('permit_root_login', False) %}yes{% else %}no{% endif %}
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication {% if server.get('public_key_auth', True) %}yes{% else %}no{% endif %}
AuthorizedKeysFile %h/.ssh/authorized_keys
{%- if server.authorized_keys_command is defined %}
AuthorizedKeysCommand {{ server.authorized_keys_command.command }}
{% if (grains['os_family'] == 'RedHat' and grains['osmajorrelease'] != '6') or grains['os_family'] != 'RedHat' %}
{%- if server.authorized_keys_command.user is defined %}
AuthorizedKeysCommandUser {{ server.authorized_keys_command.get('User', 'nobody') }}
{%- endif %}
{%- endif %}
{%- endif %}
{%- if server.force_command is defined %}
ForceCommand {{ server.force_command }}
{%- endif %}
{% if server.get('deny_users', False) %}
DenyUsers {{ server.deny_users|join(' ') }}
{% endif %}
{% if server.get('allow_users', False) %}
AllowUsers {{ server.allow_users|join(' ') }}
{% endif %}
{% if server.get('deny_groups', False) %}
DenyGroups {{ server.deny_groups|join(' ') }}
{% endif %}
{% if server.get('allow_groups', False) %}
AllowGroups {{ server.allow_groups|join(' ') }}
{% endif %}
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication {% if server.get('host_auth', False) %}yes{% else %}no{% endif %}
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
PasswordAuthentication {% if server.get('password_auth', True) %}yes{% else %}no{% endif %}
# Kerberos options
{%- if server.get('kerberos_auth', False) %}
KerberosAuthentication yes
{%- else %}
KerberosAuthentication no
{%- endif %}
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
# GSSAPI options
{%- if server.get('gssapi_auth', False) %}
GSSAPIAuthentication yes
{%- else %}
GSSAPIAuthentication no
{%- endif %}
#GSSAPICleanupCredentials yes
{%- if server.use_dns is defined %}
UseDNS {{ server.use_dns }}
{%- endif %}
X11Forwarding {% if server.get('x11', {}).get('forwarding', True) %}yes{% else %}no{% endif %}
X11DisplayOffset {{ server.get('x11', {}).get('display_offset', '10') }}
PrintMotd {% if server.get('print_motd', False) %}yes{% else %}no{% endif %}
PrintLastLog {% if server.get('print_lastlog', True) %}yes{% else %}no{% endif %}
TCPKeepAlive {{ server.get('alive', {}).get('keep','yes') }}
#UseLogin no
{%- if server.get('alive', {'interval': None}).interval is number %}
ClientAliveInterval {{ server.alive.interval }}
{% endif %}
{%- if server.get('alive', {'count': None}).count is number %}
ClientAliveCountMax {{ server.alive.count }}
{% endif %}
{%- if server.max_sessions is defined %}
MaxSessions {{ server.max_sessions }}
{%- else %}
MaxSessions 10
{%- endif %}
{%- if server.max_startups is defined %}
MaxStartups {{ server.max_startups }}
{%- else %}
#MaxStartups 10:30:60
{%- endif %}
{%- if server.banner is defined %}
Banner /etc/banner
{%- else %}
#Banner /etc/banner
{%- endif %}
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
{%- if server.get('accept_env', [])|length > 0 %}
AcceptEnv {{ server.accept_env|join(' ') }}
{%- endif %}
Subsystem sftp {{ server.lib_dir }}/sftp-server
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
{%- if server.get('dss_enabled', false) %}
PubkeyAcceptedKeyTypes=+ssh-dss
{%- endif %}