1
0

preseed_key.rst 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .. _tutorial-preseed-key:
  2. ================================
  3. Preseed Minion with Accepted Key
  4. ================================
  5. In some situations, it is not convenient to wait for a minion to start before
  6. accepting its key on the master. For instance, you may want the minion to
  7. bootstrap itself as soon as it comes online. You may also want to let your
  8. developers provision new development machines on the fly.
  9. .. seealso:: Many ways to preseed minion keys
  10. Salt has other ways to generate and pre-accept minion keys in addition to
  11. the manual steps outlined below.
  12. salt-cloud performs these same steps automatically when new cloud VMs are
  13. created (unless instructed not to).
  14. salt-api exposes an HTTP call to Salt's REST API to :py:class:`generate and
  15. download the new minion keys as a tarball
  16. <salt.netapi.rest_cherrypy.app.Keys>`.
  17. There is a general four step process to do this:
  18. 1. Generate the keys on the master:
  19. .. code-block:: bash
  20. root@saltmaster# salt-key --gen-keys=[key_name]
  21. Pick a name for the key, such as the minion's id.
  22. 2. Add the public key to the accepted minion folder:
  23. .. code-block:: bash
  24. root@saltmaster# cp key_name.pub /etc/salt/pki/master/minions/[minion_id]
  25. It is necessary that the public key file has the same name as your minion id.
  26. This is how Salt matches minions with their keys. Also note that the pki folder
  27. could be in a different location, depending on your OS or if specified in the
  28. master config file.
  29. 3. Distribute the minion keys.
  30. There is no single method to get the keypair to your minion. The difficulty is
  31. finding a distribution method which is secure. For Amazon EC2 only, an AWS best
  32. practice is to use IAM Roles to pass credentials. (See blog post,
  33. https://aws.amazon.com/blogs/security/using-iam-roles-to-distribute-non-aws-credentials-to-your-ec2-instances/ )
  34. .. admonition:: Security Warning
  35. Since the minion key is already accepted on the master, distributing
  36. the private key poses a potential security risk. A malicious party
  37. will have access to your entire state tree and other sensitive data if they
  38. gain access to a preseeded minion key.
  39. 4. Preseed the Minion with the keys
  40. You will want to place the minion keys before starting the salt-minion daemon:
  41. .. code-block:: bash
  42. /etc/salt/pki/minion/minion.pem
  43. /etc/salt/pki/minion/minion.pub
  44. Once in place, you should be able to start salt-minion and run ``salt-call
  45. state.apply`` or any other salt commands that require master authentication.