hosting-repositories.rst 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. .. include:: ../global.rst.inc
  2. .. highlight:: none
  3. .. _hosting_repositories:
  4. Hosting repositories
  5. ====================
  6. This sections shows how to provide repository storage securely for users.
  7. Repositories are accessed through SSH. Each user of the service should
  8. have her own login which is only able to access the user's files.
  9. Technically it would be possible to have multiple users share one login,
  10. however, separating them is better. Separate logins increase isolation
  11. and are thus an additional layer of security and safety for both the
  12. provider and the users.
  13. For example, if a user manages to breach ``borg serve`` then she can
  14. only damage her own data (assuming that the system does not have further
  15. vulnerabilities).
  16. Use the standard directory structure of the operating system. Each user
  17. is assigned a home directory and repositories of the user reside in her
  18. home directory.
  19. The following ``~user/.ssh/authorized_keys`` file is the most important
  20. piece for a correct deployment. It allows the user to log in via
  21. their public key (which must be provided by the user), and restricts
  22. SSH access to safe operations only.
  23. ::
  24. command="borg serve --restrict-to-repository /home/<user>/repository",restrict
  25. <key type> <key> <key host>
  26. .. note:: The text shown above needs to be written on a **single** line!
  27. .. warning::
  28. If this file should be automatically updated (e.g. by a web console),
  29. pay **utmost attention** to sanitizing user input. Strip all whitespace
  30. around the user-supplied key, ensure that it **only** contains ASCII
  31. with no control characters and that it consists of three parts separated
  32. by a single space. Ensure that no newlines are contained within the key.
  33. The ``restrict`` keyword enables all restrictions, i.e. disables port, agent
  34. and X11 forwarding, as well as disabling PTY allocation and execution of ~/.ssh/rc.
  35. If any future restriction capabilities are added to authorized_keys
  36. files they will be included in this set.
  37. The ``command`` keyword forces execution of the specified command line
  38. upon login. This must be ``borg serve``. The ``--restrict-to-repository``
  39. option permits access to exactly **one** repository. It can be given
  40. multiple times to permit access to more than one repository.
  41. The repository may not exist yet; it can be initialized by the user,
  42. which allows for encryption.
  43. Refer to the `sshd(8) <https://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8>`_
  44. man page for more details on SSH options.
  45. See also :ref:`borg_serve`