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.

58 lines
1.7KB

  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', 'ed25519'] %}
  14. {% if salt['pillar.get']('openssh:generate_' ~ keyType ~ '_keys', False) %}
  15. ssh_generate_host_{{ keyType }}_key:
  16. cmd.run:
  17. {%- if salt['pillar.get']('openssh:generate_' ~ keyType ~ '_size', False) %}
  18. {%- set keySize = salt['pillar.get']('openssh:generate_' ~ keyType ~ '_size', 4096) %}
  19. - name: ssh-keygen -t {{ keyType }} -b {{ keySize }} -N '' -f /etc/ssh/ssh_host_{{ keyType }}_key
  20. {%- else %}
  21. - name: ssh-keygen -t {{ keyType }} -N '' -f /etc/ssh/ssh_host_{{ keyType }}_key
  22. {%- endif %}
  23. - creates: /etc/ssh/ssh_host_{{ keyType }}_key
  24. - user: root
  25. {% elif salt['pillar.get']('openssh:absent_' ~ keyType ~ '_keys', False) %}
  26. ssh_host_{{ keyType }}_key:
  27. file.absent:
  28. - name: /etc/ssh/ssh_host_{{ keyType }}_key
  29. ssh_host_{{ keyType }}_key.pub:
  30. file.absent:
  31. - name: /etc/ssh/ssh_host_{{ keyType }}_key.pub
  32. {% elif salt['pillar.get']('openssh:provide_' ~ keyType ~ '_keys', False) %}
  33. ssh_host_{{ keyType }}_key:
  34. file.managed:
  35. - name: /etc/ssh/ssh_host_{{ keyType }}_key
  36. - contents_pillar: 'openssh:{{ keyType }}:private_key'
  37. - user: root
  38. - mode: 600
  39. - require_in:
  40. - service: {{ openssh.service }}
  41. ssh_host_{{ keyType }}_key.pub:
  42. file.managed:
  43. - name: /etc/ssh/ssh_host_{{ keyType }}_key.pub
  44. - contents_pillar: 'openssh:{{ keyType }}:public_key'
  45. - user: root
  46. - mode: 600
  47. - require_in:
  48. - service: {{ openssh.service }}
  49. {% endif %}
  50. {% endfor %}