Protocol 2

Port {{ sshd_port }}

{% if ansible_distribution_major_version|int == 6 %}
KexAlgorithms diffie-hellman-group-exchange-sha256
MACs hmac-sha2-512,hmac-sha2-256
Ciphers aes256-ctr,aes192-ctr,aes128-ctr
{% elif ansible_distribution_major_version|int == 7 %}
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256
Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
{% else %}
# This system is following system-wide crypto policy. The changes to
# crypto properties (Ciphers, MACs, ...) will not have any effect in
# this or following included files. To override some configuration option,
# write it before this block or include it before this file.
# Please, see manual pages for update-crypto-policies(8) and sshd_config(5).
# Also look in /usr/lib/systemd/system/sshd.service for how it is called.
{% endif %}

{% if ansible_distribution_major_version|int >= 9 and ansible_distribution == 'RedHat' %}
# To modify the system-wide sshd configuration, create a  *.conf  file under
#  /etc/ssh/sshd_config.d/  which will be automatically included below
Include /etc/ssh/sshd_config.d/*.conf
{% endif %} 
{% if ansible_distribution_major_version|int >= 36 and ansible_distribution == 'Fedora' %}
# To modify the system-wide sshd configuration, create a  *.conf  file under
#  /etc/ssh/sshd_config.d/  which will be automatically included below
Include /etc/ssh/sshd_config.d/*.conf
{% endif %} 


HostKey /etc/ssh/ssh_host_rsa_key
{% if not ansible_hostname.startswith(('pkgs01','pagure02')) %}
HostKey /etc/ssh/ssh_host_ed25519_key
{% endif %}

HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub
{% if not ansible_hostname.startswith(('pkgs01','pagure02')) %}
HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub
{% endif %}

SyslogFacility AUTHPRIV
LogLevel VERBOSE

PermitRootLogin without-password
StrictModes yes
AuthorizedKeysFile      .ssh/authorized_keys

PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication no
UsePAM yes

AllowAgentForwarding no
X11Forwarding no
PermitTunnel no

{% if ansible_distribution_major_version|int == 6 %}
UsePrivilegeSeparation yes
{% elif ansible_distribution_major_version|int == 7 %}
UsePrivilegeSeparation sandbox
{% endif %}

# Accept locale-related environment
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

{% if sshd_keyhelper %}
{% if inventory_hostname.startswith('pkgs') %}
AuthorizedKeysCommandUser nobody
AuthorizedKeysCommand /usr/local/bin/ssh_wrapper "%u"
{% else %}
AuthorizedKeysCommandUser git
AuthorizedKeysCommand /usr/libexec/pagure/keyhelper.py "%u" "%h" "%t" "%f"
{% endif %}
{% else %}
AuthorizedKeysCommandUser nobody
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
{% endif %}
Subsystem sftp internal-sftp
