Saltstack Official OpenSSH Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2KB

  1. {% from "openssh/map.jinja" import openssh with context %}
  2. include:
  3. - openssh
  4. sshd_config:
  5. file.managed:
  6. - name: {{ openssh.sshd_config }}
  7. - source: {{ openssh.sshd_config_src }}
  8. - template: jinja
  9. - user: root
  10. - mode: 644
  11. - watch_in:
  12. - service: openssh
  13. {% for keyType in ['ecdsa', 'dsa', 'rsa'] %}
  14. {% if salt['pillar.get']('openssh:generate_' ~ keyType ~ '_keys', False) %}
  15. ssh_generate_host_{{ keyType }}_key:
  16. cmd.run:
  17. - name: ssh-keygen -t {{ keyType }} -N '' -f /etc/ssh/ssh_host_{{ keyType }}_key
  18. - creates: /etc/ssh/ssh_host_{{ keyType }}_key
  19. - user: root
  20. {% elif salt['pillar.get']('openssh:provide_' ~ keyType ~ '_keys', False) %}
  21. ssh_host_{{ keyType }}_key:
  22. file.managed:
  23. - name: /etc/ssh/ssh_host_{{ keyType }}_key
  24. - contents_pillar: 'openssh:{{ keyType }}:private_key'
  25. - user: root
  26. - mode: 600
  27. - require_in:
  28. - service: {{ openssh.service }}
  29. ssh_host_{{ keyType }}_key.pub:
  30. file.managed:
  31. - name: /etc/ssh/ssh_host_{{ keyType }}_key.pub
  32. - contents_pillar: 'openssh:{{ keyType }}:public_key'
  33. - user: root
  34. - mode: 600
  35. - require_in:
  36. - service: {{ openssh.service }}
  37. {% endif %}
  38. {% endfor %}