| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | .. include:: ../global.rst.inc.. highlight:: none.. _hosting_repositories:Hosting repositories====================This sections shows how to provide repository storage securely for users.Optionally, each user can have a storage quota.Repositories are accessed through SSH. Each user of the service shouldhave her own login which is only able to access the user's files.Technically it would be possible to have multiple users share one login,however, separating them is better. Separate logins increase isolationand are thus an additional layer of security and safety for both theprovider and the users.For example, if a user manages to breach ``borg serve`` then she canonly damage her own data (assuming that the system does not have furthervulnerabilities).Use the standard directory structure of the operating system. Each useris assigned a home directory and repositories of the user reside in herhome directory.The following ``~user/.ssh/authorized_keys`` file is the most importantpiece for a correct deployment. It allows the user to log in viatheir public key (which must be provided by the user), and restrictsSSH access to safe operations only.::  command="borg serve --restrict-to-repository /home/<user>/repository",restrict  <key type> <key> <key host>.. note:: The text shown above needs to be written on a **single** line!.. warning::    If this file should be automatically updated (e.g. by a web console),    pay **utmost attention** to sanitizing user input. Strip all whitespace    around the user-supplied key, ensure that it **only** contains ASCII    with no control characters and that it consists of three parts separated    by a single space. Ensure that no newlines are contained within the key.The ``restrict`` keyword enables all restrictions, i.e. disables port, agentand X11 forwarding, as well as disabling PTY allocation and execution of ~/.ssh/rc.If any future restriction capabilities are added to authorized_keysfiles they will be included in this set.The ``command`` keyword forces execution of the specified command lineupon login. This must be ``borg serve``. The ``--restrict-to-repository``option permits access to exactly **one** repository. It can be givenmultiple times to permit access to more than one repository.The repository may not exist yet; it can be initialized by the user,which allows for encryption.**Storage quotas** can be enabled by adding the ``--storage-quota`` optionto the ``borg serve`` command line::    restrict,command="borg serve --storage-quota 20G ..." ...The storage quotas of repositories are completely independent. If aclient is able to access multiple repositories, each repositorycan be filled to the specified quota.If storage quotas are used, ensure that all deployed Borg releasessupport storage quotas.Refer to :ref:`internals_storage_quota` for more details on storage quotas.**Specificities: Append-only repositories**Running ``borg init`` via a ``borg serve --append-only`` server will **not**create a repository that is configured to be append-only by its repositoryconfig.But, ``--append-only`` arguments in ``authorized_keys`` will override therepository config, therefore append-only mode can be enabled on a key by keybasis.Refer to the `sshd(8) <https://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/sshd.8>`_man page for more details on SSH options.See also :ref:`borg_serve`
 |