sshd_config.legacy.j2 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. {% if ansible_controlled is defined and ansible_controlled != "" %}
  2. #
  3. # {{ ansible_controlled }}
  4. #
  5. {% endif %}
  6. # Package generated configuration file
  7. # See the sshd_config(5) manpage for details
  8. # What ports, IPs and protocols we listen for
  9. {% for port in ssh_ports %}
  10. Port {{ port }}
  11. {% endfor %}
  12. # Use these options to restrict which interfaces/protocols sshd will bind to
  13. #ListenAddress ::
  14. #ListenAddress 0.0.0.0
  15. Protocol 2
  16. # HostKeys for protocol version 2
  17. HostKey /etc/ssh/ssh_host_rsa_key
  18. HostKey /etc/ssh/ssh_host_dsa_key
  19. {% if ansible_lsb.major_release|int >= 7 %}
  20. HostKey /etc/ssh/ssh_host_ecdsa_key
  21. {% endif %}
  22. {% if ansible_lsb.major_release|int >= 8 %}
  23. HostKey /etc/ssh/ssh_host_ed25519_key
  24. {% endif %}
  25. #Privilege Separation is turned on for security
  26. UsePrivilegeSeparation yes
  27. {% if not ssh_usedns %}
  28. # Enable/Disable reverse DNS check
  29. # Avois long lag in case of IPv6 connection with no reverse configured
  30. UseDns no
  31. {% endif %}
  32. # Lifetime and size of ephemeral version 1 server key
  33. KeyRegenerationInterval 3600
  34. ServerKeyBits 1024
  35. # Logging
  36. SyslogFacility AUTH
  37. LogLevel INFO
  38. # Authentication:
  39. LoginGraceTime 120
  40. PermitRootLogin without-password
  41. StrictModes yes
  42. RSAAuthentication yes
  43. PubkeyAuthentication yes
  44. #AuthorizedKeysFile %h/.ssh/authorized_keys
  45. # Don't read the user's ~/.rhosts and ~/.shosts files
  46. IgnoreRhosts yes
  47. # For this to work you will also need host keys in /etc/ssh_known_hosts
  48. RhostsRSAAuthentication no
  49. # similar for protocol version 2
  50. HostbasedAuthentication no
  51. # Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
  52. #IgnoreUserKnownHosts yes
  53. # To enable empty passwords, change to yes (NOT RECOMMENDED)
  54. PermitEmptyPasswords no
  55. # Change to yes to enable challenge-response passwords (beware issues with
  56. # some PAM modules and threads)
  57. ChallengeResponseAuthentication no
  58. # Change to no to disable tunnelled clear text passwords
  59. #PasswordAuthentication yes
  60. # Kerberos options
  61. #KerberosAuthentication no
  62. #KerberosGetAFSToken no
  63. #KerberosOrLocalPasswd yes
  64. #KerberosTicketCleanup yes
  65. # GSSAPI options
  66. #GSSAPIAuthentication no
  67. #GSSAPICleanupCredentials yes
  68. X11Forwarding no
  69. X11DisplayOffset 10
  70. PrintMotd no
  71. PrintLastLog yes
  72. TCPKeepAlive yes
  73. #UseLogin no
  74. #MaxStartups 10:30:60
  75. #Banner /etc/issue.net
  76. # Allow client to pass locale environment variables
  77. AcceptEnv LANG LC_*
  78. Subsystem sftp /usr/lib/openssh/sftp-server
  79. # Set this to 'yes' to enable PAM authentication, account processing,
  80. # and session processing. If this is enabled, PAM authentication will
  81. # be allowed through the ChallengeResponseAuthentication and
  82. # PasswordAuthentication. Depending on your PAM configuration,
  83. # PAM authentication via ChallengeResponseAuthentication may bypass
  84. # the setting of "PermitRootLogin without-password".
  85. # If you just want the PAM account and session checks to run without
  86. # PAM authentication, then enable this but set PasswordAuthentication
  87. # and ChallengeResponseAuthentication to 'no'.
  88. UsePAM yes
  89. # Maximum number of authentication attempts permitted per connection
  90. MaxAuthTries 3
  91. {% if ssh_allowed_users %}
  92. # Define users allowed to login
  93. AllowUsers {{ ssh_allowed_users | join(' ') }}
  94. {% endif %}
  95. {% if not ssh_allowed_users and ssh_allowed_groups %}
  96. # Define users groups allowed to login
  97. AllowGroups {{ ssh_allowed_groups | join(' ') }}
  98. {% endif %}
  99. {% if ssh_local_config is defined and ssh_local_config %}
  100. # Additional parameters
  101. {{ ssh_local_config|join('\n') }}
  102. {% endif %}