You back up three clients into one datastore. All three use the same SSH login, so each client can read the files of the other two. Now you can give each client its own SSH sub-user. A sub-user has its own keys and sees only the folders that you grant to it.
- Each datastore can now have SSH sub-users. A sub-user has its own SSH keys and can use only the folders that you grant to it.
- The login of a sub-user is the main login, a dot and the sub-user name, for example customer<ID>.client-a. It connects to the same host as the main login.
- Sub-users work with SFTP, rsync and Borg. They cannot run zfs. Proxmox Backup Server access does not use SSH, so sub-users do not change it.
- You add a sub-user in the dashboard under Settings > SSH / SFTP. Resellers can also manage sub-users through the Reseller API.
- When you delete a sub-user, its folders and files stay in the datastore. The main login keeps full access to all folders.
One datastore, one login per client
Until now, a datastore had one SSH login, customer<ID>. Every key that you added to it could reach every folder: sftp, borg and rsync, and everything below them. That is correct for one owner. It is a problem when you store data for several clients, for example as an MSP. You had to trust each client with the data of all the others, or book one datastore per client.
A sub-user solves this. You create it in the datastore, give it the public keys of one client, and select its folders. The client connects with its own login and sees only those folders. The other folders are not visible to it.
The login is the main login, a dot and the sub-user name:
sftp -i /path/to/client-key customer<ID>.client-a@<host>The client keeps its private key. You add only its public key.
Add a sub-user
In the dashboard, open your datastore, go to Settings and select SSH / SFTP. Below the main SSH keys, click Add user.
Use lowercase letters, digits and -, at most 32 characters, for example client-a. The first character must be a letter or a digit. The form shows the login and an sftp command for it.
One key per line, in OpenSSH format (for example ssh-ed25519 ...). A sub-user can have up to 50 keys.
Expand sftp, borg or rsync and tick the folders the sub-user may use. A ticked folder includes everything below it. To make a new folder, click the folder icon next to its parent.
Add an optional comment, then click Save. A folder that does not exist yet is created now. The table shows the login to give to your client.
To change the keys or the folders of a sub-user, click the edit icon. The change applies at the next login, because the server reads the folders of the sub-user from the service each time the sub-user logs in.
What a sub-user can do
A sub-user can read and write in its granted folders. It cannot see the other folders. The folders above its own are read-only, so it cannot put files next to them.
| Main login | Sub-user | |
|---|---|---|
| Login | customer<ID> | customer<ID>.<name> |
| Folders | All | Only the granted folders |
| SFTP, rsync, Borg | Yes | Yes, in its folders |
ls, du, rm, mkdir and other commands | Yes | Yes, in its folders |
zfs | Yes | No |
Each tool sees the folders in its usual place. In an SFTP session, the granted sftp folders show under /data, and the granted borg and rsync folders show under /borg and /rsync. FileZilla, WinSCP and other graphical clients work the same way: enter the full login as the user name. If you use SFTP from Nextcloud, the setup in Connect Nextcloud to Remote SFTP Storage works with a sub-user login too.
For rsync, paths start inside your rsync folder. A sub-user with the folder rsync/acme/daily writes to acme/daily/:
rsync -avz -e "ssh -i /path/to/client-key" \
/srv/backup/ customer<ID>.client-a@<host>:acme/daily/A write to a folder that is not granted fails with "Read-only file system".
For Borg, put the repository inside a granted folder. For a sub-user with the folder borg/acme:
export BORG_RSH="ssh -i /path/to/client-key"
borg init --encryption=repokey customer<ID>.client-a@<host>:./borg/acme/repo
borg create customer<ID>.client-a@<host>:./borg/acme/repo::{now} /path/to/filesSub-users are SSH logins. Backups from Proxmox VE to the Proxmox Backup Server datastore use the datastore credentials, not SSH. To split that access, use credentials and ACLs. A sub-user does not change them.
How the isolation works
The service does not only hide the other folders. It builds a separate view of the datastore for each session:
- For each login, the server reads the granted folders of the sub-user from the service. A key line for a deleted sub-user cannot log in, even if it is still on the host.
- The session runs in a sandbox. The sandbox has an empty, read-only datastore mount that holds only the granted folders. For commands other than SFTP, the sandbox also hides the processes of the host.
- A granted folder that contains a symbolic link stops the login. A link cannot point the session at the folder of another client.
- Folder names cannot start with a dot or a dash, so a grant like
..is not possible.
The main login keeps full access to all folders, including the folders of your sub-users. Do not give the main login keys to a client. Give each client a sub-user.
Remove a sub-user
Click the delete icon. The service removes the key lines of the sub-user from the host, and the next login of that sub-user fails. Its folders and files stay in the datastore. The main login can still use them or delete them.
Manage sub-users through the Reseller API
Resellers can do the same steps through the Reseller API:
GET /reseller/datastore/{id}/ssh-users
POST /reseller/datastore/{id}/ssh-users
PATCH /reseller/datastore/{id}/ssh-users/{name}
DELETE /reseller/datastore/{id}/ssh-users/{name}
GET /reseller/datastore/{id}/folders
POST /reseller/datastore/{id}/foldersA folder in a request starts with sftp, borg or rsync, for example sftp/acme or rsync/acme/daily. A sub-user can have up to 100 folders.
Wrapping Up
SSH sub-users give each client its own login into a shared datastore, with its own keys and only its own folders. They work with SFTP, rsync and Borg. Add them in the dashboard under Settings > SSH / SFTP, or through the Reseller API. For the commands of the main login, see the SFTP, rsync, Borg and ZFS docs.
The docs show the steps, the folder rules and the commands for SFTP, rsync and Borg.
Read the SSH users docs





