Saltstack Official OpenSSH Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

README.rst 5.9KB

11 lat temu
11 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. openssh
  2. =======
  3. Install and configure an openssh server.
  4. .. note::
  5. See the full `Salt Formulas installation and usage instructions
  6. <http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html>`_.
  7. Available states
  8. ================
  9. .. contents::
  10. :local:
  11. ``openssh``
  12. -----------
  13. Installs the ``openssh`` server package and service.
  14. ``openssh.auth``
  15. -----------
  16. Manages SSH certificates for users.
  17. ``openssh.auth_map``
  18. -----------
  19. Same functionality as openssh.auth but with a simplified Pillar syntax.
  20. Plays nicely with `Pillarstack
  21. <https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.stack.html>`_.
  22. ``openssh.banner``
  23. ------------------
  24. Installs a banner that users see when SSH-ing in.
  25. ``openssh.client``
  26. ------------------
  27. Installs the openssh client package.
  28. ``openssh.config``
  29. ------------------
  30. Installs the ssh daemon configuration file included in this formula
  31. (under "openssh/files"). This configuration file is populated
  32. by values from pillar. ``pillar.example`` results in the generation
  33. of the default ``sshd_config`` file on Debian Wheezy.
  34. It is highly recommended ``PermitRootLogin`` is added to pillar
  35. so root login will be disabled.
  36. ``openssh.config_ini``
  37. ----------------------
  38. Version of managing ``sshd_config`` that uses the
  39. `ini_managed.option_present <https://docs.saltstack.com/en/latest/ref/states/all/salt.states.ini_manage.html>`_
  40. state module, so it enables to override only one or
  41. multiple values and keeping the defaults shipped by your
  42. distribution.
  43. ``openssh.known_hosts``
  44. -----------------------
  45. Manages the side-wide ssh_known_hosts file and fills it with the
  46. public SSH host keys of your minions (collected via the Salt mine)
  47. and of hosts listed in you pillar data. It's possible to include
  48. minions managed via ``salt-ssh`` by using the ``known_hosts_salt_ssh`` renderer.
  49. You can restrict the set of minions
  50. whose keys are listed by using the pillar data ``openssh:known_hosts:target``
  51. and ``openssh:known_hosts:tgt_type`` (those fields map directly to the
  52. corresponding attributes of the ``mine.get`` function).
  53. The **Salt mine** is used to share the public SSH host keys, you must thus
  54. configure it accordingly on all hosts that must export their keys. Two
  55. mine functions are required, one that exports the keys (one key per line,
  56. as they are stored in ``/etc/ssh/ssh_host_*_key.pub``) and one that defines
  57. the public hostname that the keys are associated to. Here's the way to
  58. setup those functions through pillar::
  59. # Required for openssh.known_hosts
  60. mine_functions:
  61. public_ssh_host_keys:
  62. mine_function: cmd.run
  63. cmd: cat /etc/ssh/ssh_host_*_key.pub
  64. python_shell: True
  65. public_ssh_host_names:
  66. mine_function: grains.get
  67. key: id
  68. The above example assumes that the minion identifier is a valid DNS name
  69. that can be used to connect to the host. If that's not the case, you might
  70. want to use the ``fqdn`` grain instead of the ``id`` one. The above example
  71. also uses the default mine function names used by this formula. If you have to
  72. use other names, then you should indicate the names to use in pillar keys
  73. ``openssh:known_hosts:mine_keys_function`` and
  74. ``openssh:known_hosts:mine_hostname_function``.
  75. You can also integrate alternate DNS names of the various hosts in the
  76. ssh_known_hosts files. You just have to list all the alternate DNS names as a
  77. list in the ``openssh:known_hosts:aliases`` pillar key. Whenever the IPv4 or
  78. IPv6 behind one of those DNS entries matches an IPv4 or IPv6 behind the
  79. official hostname of a minion, the alternate DNS name will be associated to the
  80. minion's public SSH host key.
  81. To **include minions managed via salt-ssh** install the ``known_hosts_salt_ssh`` renderer::
  82. # in pillar.top:
  83. '*':
  84. - openssh.known_hosts_salt_ssh
  85. # In your salt/ directory:
  86. # Link the pillar file:
  87. mkdir pillar/openssh
  88. ln -s ../../formulas/openssh-formula/_pillar/known_hosts_salt_ssh.sls pillar/openssh/known_hosts_salt_ssh.sls
  89. Pillar ``openssh:known_hosts:salt_ssh`` overrides the Salt Mine.
  90. The pillar is fed by a host key cache. Populate it by applying ``openssh.gather_host_keys``
  91. to the salt master::
  92. salt 'salt-master.example.test' state.apply openssh.gather_host_keys
  93. The state tries to fetch the SSH host keys via ``salt-ssh``. It calls the command as user
  94. ``salt-master`` by default. The username can be changed via Pillar::
  95. openssh:
  96. known_hosts:
  97. salt_ssh:
  98. user: salt-master
  99. It's possible to define aliases for certain hosts::
  100. openssh:
  101. known_hosts:
  102. salt_ssh:
  103. public_ssh_host_names:
  104. minion.id:
  105. - minion.id
  106. - alias.of.minion.id
  107. You can use a cronjob to populate a host key cache::
  108. # crontab -e -u salt-master
  109. 0 1 * * * salt 'salt-master.example.test' state.apply openssh.gather_host_keys
  110. Or just add it to your salt master::
  111. # states/top.sls:
  112. base:
  113. salt:
  114. - openssh.known_hosts_salt_ssh
  115. You can also use a "golden" known hosts file. It overrides the keys fetched by the cronjob.
  116. This lets you re-use the trust estabished in the salt-ssh user's known_hosts file::
  117. # In your salt/ directory: (Pillar expects the file here.)
  118. ln -s /home/salt-master/.ssh/known_hosts ./known_hosts
  119. # Test it:
  120. salt-ssh 'minion' pillar.get 'openssh:known_hosts:salt_ssh'
  121. To add **public keys of hosts not among your minions** list them under the
  122. pillar key ``openssh:known_hosts:static``::
  123. openssh:
  124. known_hosts:
  125. static:
  126. github.com: 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq[...]'
  127. gitlab.com: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABA[...]'
  128. Pillar ``openssh:known_hosts:static`` overrides ``openssh:known_hosts:salt_ssh``.
  129. To **include localhost** and local IP addresses (``127.0.0.1`` and ``::1``) use this Pillar::
  130. openssh:
  131. known_hosts:
  132. include_localhost: True
  133. ``openssh.moduli``
  134. -----------------------
  135. Manages the system wide ``/etc/ssh/moduli`` file.