Repository navigation
Local Directories
Since 3.5.2 an administrator can share directories of the WebSSH server itself as file sources: a Docker bind mount, a folder of the Unraid array, a directory of an LXC/Incus container or a network share mounted on the host. They appear in the file workspace as Local: next to the SSH, SFTP and SMB sources and work like them: list, search and filter, preview, download, folder download as ZIP, the editor, uploads, new files and folders, rename and move, delete, Unix permissions and copies to and from every other source.
The feature is off until LOCAL_SOURCES_FILE names a configuration file.
Nothing is shared by default, and every source is read-only unless the file
says otherwise.
Read this before you share a directory.
-
One identity. With SFTP and SMB each user signs in to the server with
their own account, and the server enforces permissions and keeps its own
log. A local source has no such second line: every access runs as the
account of the WebSSH process (
websshfor the native service,1000:1000in the Docker image,99:100with the Unraid template). Every account a source is shared with sees and changes the same files with the same operating-system rights. WebSSH never gets more rights than its process has, so read-only mounts and file permissions set by the operating system stay in force. - Not a replacement for per-user separation. When users must not see each other's files, give each of them an SFTP account on the server instead.
- Shared with names and roles, checked on the server. A source is offered only to the accounts and roles the file lists. The check runs on the server each time the source is opened, against the account as the database has it at that moment. A source that is not shared with an account answers exactly like one that does not exist. Locked accounts and recovery sessions never open a source.
-
Names are reserved. A local account name listed in
userscannot be registered by a visitor; only an administrator can create it, as withADMIN_USERS. Otherwise the first person to register the name would get the files. For the same reason an account GitHub created under such a name cannot turn itself into the local account by unlinking GitHub. -
Rights are taken back at once. When an administrator is demoted, the
local sources the account has open are closed, so a source shared with
adminis not kept until the browser reconnects. -
Confined to the directory. Every access goes through the directory
opened at the start of the session (Go's
os.Root)...never leaves it, and a link that points outside, absolute or relative, is refused. The last element of a path is never followed: a link is listed and can be renamed or deleted, but nothing is read, written or changed through it. FIFOs, sockets and device files are listed but never opened. -
Protected directories. A source may not be, contain or lie inside
DATA_DIR,BACKUP_TEMP_DIRor one of/proc,/sys,/dev,/etcand/boot, and may not be/or/run. The comparison uses device and inode numbers, so a bind mount that showsDATA_DIRor a part of it under another path is found as well. For the system directories only the directories themselves are compared: a part of/etcthat you bind-mount into a source, such as/etc/sshat/srv/shared/ssh, is shared like any other folder, so do not mount system files into a source. A source whose root overlaps one of them is shown as blocked. WhenDATA_DIRappears somewhere below the root of a source, for example because the source is a whole array andDATA_DIRis one of its folders mounted into the container, the source opens, but every folder it enters is compared too:DATA_DIRand everything in it cannot be read, listed, changed, renamed or deleted through the source, and deleting a folder that contains it is refused before anything is deleted. Renaming a folder that contains it is not refused; on the host it movesDATA_DIRalong.
Do not share a directory that contains
DATA_DIR. The protection above works by device and inode. It cannot seeDATA_DIRwhen it reaches the source through another file system: on Unraid,/mnt/cache/appdataand/mnt/user/appdataare the same files on two file systems. WithDATA_DIRon/mnt/cache/appdata/websshand/mnt/useras a read-write source, every account the source is shared with could change WebSSH's database and keys. Share the folders the accounts need (/mnt/user/media,/mnt/user/downloads) instead of the whole array, and neverappdata.
- Hard links are files: a hard link inside a source to a file elsewhere on the same file system can be read through the source. Only someone who can already write into the source and read the other file can make one; WebSSH never creates links.
Set LOCAL_SOURCES_FILE to the absolute path of a JSON file. WebSSH reads it
once at the start; restart WebSSH after a change. An invalid file stops the
start with a message naming the entry. The file must not be writable by every
user.
{
"sources": [
{
"id": "media",
"name": "Media library",
"path": "/srv/media",
"users": ["alice", "ldap:bob"],
"roles": ["admin"]
},
{
"id": "dropbox",
"name": "Drop box",
"path": "/srv/dropbox",
"mode": "read-write",
"users": ["alice"],
"file_mode": "0640",
"dir_mode": "0750"
}
]
}| Member | Default | Meaning |
|---|---|---|
id |
required | 1 to 64 letters, digits, _ or -, starting with a letter or digit. Unique. Appears in the source id (local:<id>) and in the audit log. |
name |
the id
|
Shown to users as Local: . The path is shown only to administrators. |
path |
required | Absolute path of the directory as the WebSSH process sees it (inside the container for Docker). |
mode |
read-only |
read-only or read-write. A read-only source refuses every change on the server, not only in the page. |
users |
none | Account names. alice is the local account alice, ldap:alice the account an LDAP directory provisioned, github:alice the one GitHub sign-in provisioned. Names compare without case. |
roles |
none |
admin (every administrator) and user (every account, including accounts created by self-registration and accounts an LDAP, GitHub or OIDC sign-in provisions). At least one user or role is required. With registration open, user shares the source with anyone who signs up; WebSSH logs a warning at the start in that case. |
marker |
.webssh-source |
Name of the marker file in the root of the directory, see below. |
require_marker |
true |
false turns the marker check off. Only when the directory can never be an empty mount point. |
max_operations |
8 |
File system calls that may run at the same time on this source, across all users (1–64). |
operation_timeout_seconds |
30 |
How long one call may take before the request fails (1–600). The final flush of an upload gets one more second per 8 MiB written. |
file_mode, dir_mode
|
process umask | Permission bits of new files and folders, such as "0640". Only the nine permission bits; set-user-ID, set-group-ID, sticky and "0000" are refused. |
Up to 64 sources. Unknown members are an error, so a typo never turns a setting off silently.
Create an empty file named .webssh-source in the root of the shared
directory on the mounted file system, not in the mount point underneath:
touch /srv/media/.webssh-source # while the share is mountedWhen the mount is missing, the directory is an empty mount point without the marker, and WebSSH refuses to open it instead of reading from or writing into the wrong place. WebSSH opens the directory first and looks for the marker inside the directory it holds open; a mount that appears or disappears afterwards does not change what an open source refers to. Before every change (upload, new folder, rename, delete, permissions) and once more before an upload takes its name, WebSSH checks that the configured path still leads to that directory and that the marker is still there. When the share was unmounted or another file system mounted over it in the meantime, the change fails, nothing is left behind and the source is closed; opening it again checks the path from the start. Reading from an open source is not checked this way. An open source is closed after five minutes without use and checks the marker again when it is opened next. The marker itself is not listed or included in folder downloads, and cannot be changed, renamed or deleted through WebSSH.
New files are created with what the process umask leaves of 0666, folders
of 0777. The native service runs with UMask=0077, so they are private to
the service account (0600, 0700); the Docker image keeps the usual
0022 (0644, 0755). Set file_mode and dir_mode to give a shared
group access. A replaced file keeps its permission bits and owner; when the
owner cannot be kept (another account owns the file), the replacement is
refused and the file stays as it was.
Changing permissions in the file workspace needs the instance switch for Unix
permissions (Administration → Integrations, SFTP_CHMOD_ENABLED) and a
read-write source. Only the nine permission bits of regular files and folders
can be set, never through a link.
Mount the directory and the configuration file into the container and set the variable:
services:
webssh:
environment:
- LOCAL_SOURCES_FILE=/etc/webssh-local/local-sources.json
volumes:
- webssh_data:/app/data
- webssh_recovery:/app/recovery
- ./local-sources.json:/etc/webssh-local/local-sources.json:ro
- /srv/media:/srv/media:ro # a read-only source: also read-only for the OS
- /srv/dropbox:/srv/dropbox # a read-write sourceThe container runs as 1000:1000. A read-write source must be writable by
that account on the host (chown 1000:1000 or group permissions), a
read-only source readable by it. Mount read-only sources with :ro as well:
then the operating system refuses changes even if the configuration were
wrong. The image's read-only root file system and dropped capabilities stay
as they are.
Add a Path to the template for each directory (for example container
path /srv/media, host path /mnt/user/media, access mode read-only), a
second Path for the configuration file and a Variable
LOCAL_SOURCES_FILE with the container path of the file. The template runs
the container as 99:100 (nobody:users), which can read the shares of the
array by default. For a read-write source the share needs write access for
users.
Share single folders of the array, never /mnt/user as a whole: it contains
appdata, and with it the data directory of WebSSH and of every other
container (see Protected directories above).
The unit makes the file system read-only for the service
(ProtectSystem=strict) and hides /home (ProtectHome=yes). Allow the
shared directories with a drop-in:
# /etc/systemd/system/webssh.service.d/local-sources.conf
[Service]
ReadOnlyPaths=/srv/media
ReadWritePaths=/srv/dropboxinstall -m 0640 -o root -g webssh local-sources.json /etc/webssh/local-sources.json
echo 'LOCAL_SOURCES_FILE=/etc/webssh/local-sources.json' >> /etc/webssh/webssh.env
systemctl daemon-reload && systemctl restart websshA path in ReadOnlyPaths= or ReadWritePaths= that does not exist stops
the service at the start (status=226/NAMESPACE). When a source is a mount
that may be missing, prefix the path with - (ReadOnlyPaths=-/srv/media):
the service then starts without it, the source shows Directory missing,
and a restart after the mount is back makes it available again.
With an AppArmor profile on top of the unit, add the configuration file and each directory to the profile as described in AppArmor or SELinux on top of the unit.
A directory below /home also needs BindReadOnlyPaths= or BindPaths=,
because ProtectHome=yes hides /home. The unit runs with
PrivateUsers=yes: files of other accounts appear as owned by nobody, and
only their "other" permission bits apply. A read-write source should
therefore belong to the webssh account or be writable for it through the
other bits.
In an unprivileged container, pass the host directory in as a disk device.
With Incus, shift=true maps the host owners into the container (an
idmapped mount), so a directory owned by host UID 1000 is owned by UID 1000
in the container:
incus config device add webssh media disk source=/srv/media path=/srv/media readonly=true shift=true
incus config device add webssh dropbox disk source=/srv/dropbox path=/srv/dropbox shift=trueOn Proxmox VE use a mount point (pct set <id> -mp0 /srv/media,mp=/srv/media,ro=1)
and give the directory to the container's mapped UID of the webssh
account (host UID 100000 plus its UID in the container) or use group or
other bits.
Mount the share outside WebSSH, on the host or in the container, and share
the mount point. When the server of a network share stops answering, file
system calls hang in the kernel and cannot be interrupted. WebSSH keeps that
bounded: at most max_operations calls run per source, a request fails after
operation_timeout_seconds, and the source shows Not responding in the
administration view until the calls return. Mount options make the kernel
give up instead of waiting forever:
- SSHFS:
-o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3 - CIFS:
soft(the default of current kernels) andecho_interval=15 - NFS:
soft,timeo=150,retrans=3only if failed writes are acceptable;hardkeeps waiting.
File systems without RENAME_NOREPLACE (NFS, SSHFS and other FUSE file
systems) still never have a name replaced by a rename: WebSSH links a file
under the new name, which fails if the name exists, and then removes the old
name; a folder first takes the new name with an empty placeholder folder and
is renamed over it. Where a file system has no hard links, or an AppArmor or
SELinux profile refuses them, files take the placeholder route as well; a file another program writes to that
placeholder in the moment before the rename is then replaced.
-
Status. Administration → Integrations → Local directories lists each
source with path, access, who it is shared with and its state: Ready,
Directory missing, No access for the WebSSH account, Marker file missing (mount missing?), Blocked:
overlaps a protected directory, Not responding or Error, see the server
log. A read-write source whose file system is mounted read-only (a
:robind,ReadOnlyPaths=) shows Read and write configured, but mounted read-only as its access. The page checks every source when it opens. At the start, WebSSH logslocal sources configuredwith their number and a warning for each source that cannot be used. -
Audit. Opening a source writes
LOCAL_SOURCE_OPENED, a refusalLOCAL_SOURCE_REFUSEDwith the reason (not_shared,missing,no_access,marker_missing,blocked,not_responding,error). Every change is aFILE_SOURCE_OPERATIONwithsource_kind=localandshare=<id>; like for SFTP and SMB only the last element of a path is recorded. -
Limits. An open local source counts like a Quick SFTP or SMB connection
(
QUOTA_QUICK_CONNECTION_PER_USER,QUOTA_QUICK_CONNECTION_GLOBAL) and is closed after five minutes without use. The upload, download, archive and member limits of the transfers apply unchanged. -
Free space. WebSSH keeps no reserve on a read-write source: with the
default upload limit of 5 GiB and several transfers at once, an account can
fill the file system. When
DATA_DIRlies on the same file system, as is common with Docker and Unraid, WebSSH can then no longer write its database. Put read-write sources on another file system, give the share a quota, or lowerMAX_UPLOAD_SIZE. -
Backup and restore. The files of a local source are never part of a
WebSSH backup, and neither is the configuration file. After a restore or a
move to another host, put the configuration file back, set
LOCAL_SOURCES_FILEand recreate the mounts and drop-ins. -
AppArmor and SELinux. A profile of your own must allow the shared paths:
read for read-only sources, read, write and link (
rwl) for read-write sources, and read of the configuration file. Without the link permission renames and new uploads on NFS and SSHFS take the placeholder route described above. -
Way back. 3.5.1 and earlier ignore
LOCAL_SOURCES_FILEand store nothing about local sources, so 3.5.1 starts on the data unchanged. It does not know the reservation of the names inusers, though: while it runs, a visitor can register such a name, and LDAP, GitHub or OIDC sign-in can provision it. After the next upgrade that account gets the source. Turn registration off while the older release runs, and before upgrading again check under Administration → Users that every account named inusersis the person you shared the source with.
| What you see | Cause | What to do |
|---|---|---|
| No Local: entry in the source list | the source is not shared with the account, or LOCAL_SOURCES_FILE is not set |
check users and roles; LDAP and GitHub accounts need the ldap: or github: prefix |
WebSSH does not start, the log names LOCAL_SOURCES_FILE
|
the file is invalid or writable by every user | fix the entry the message names |
| Directory missing | the path does not exist for the process | Docker: check the volume; native: check the path and the drop-in |
| No access for the WebSSH account | the process account may not enter the directory; in a container, the owner is not mapped (shown as nobody) |
give the account read and search permission; Incus: add the disk with shift=true
|
| Marker file missing | the share is not mounted, or the marker was never created | mount the share; create .webssh-source on the mounted file system |
| Blocked | the path is, contains or lies in a protected directory | share another directory |
| This folder belongs to WebSSH itself when opening a folder |
DATA_DIR, BACKUP_TEMP_DIR or a system directory is mounted below the source |
share a directory that does not contain it |
| Not responding | a network share hangs | check the server of the share and the mount options above |
| Uploads fail with permission denied | the process account may not write there, or the mount is read-only | Docker: owner 1000:1000; native: ReadWritePaths= and owner webssh
|
| Read and write configured, but mounted read-only | the source is read-write, but the file system is mounted read-only for WebSSH |
Docker: drop :ro from the volume; native: ReadWritePaths= instead of ReadOnlyPaths=; or set "mode": "read-only"
|
| A change fails with unmounted or replaced on the server | the share was unmounted or another file system was mounted over the path after the source was opened | mount the share again and reopen the source |
WebSSH documentation - Project - Issues - Discussions - Security
This Wiki is published from the versioned docs/wiki source. Please propose documentation changes through a pull request.
WebSSH Wiki
Install
- Docker and Docker Compose
- Install on Unraid
- Install in LXC, Incus or Proxmox
- Production Deployment
- Reverse Proxy and Subfolder Deployment
Update
Use WebSSH
- Overview and Dashboard
- SSH Connections and Host Keys
- Profiles, Jump Hosts and Commands
- Terminal and Persistent tmux Sessions
- SFTP and SMB File Workspace and Transfers
- Local Directories
- Automation
- Saved Passwords
- Herdr Integration
- Tailscale SSH
Accounts and sign-in
- Authentication Overview
- Users and Account Management
- Account Access Controls
- Passkeys, Authenticator Apps and Recovery Codes
- OpenID Connect
- GitHub Authentication
- LDAP and Active Directory
Operate
- Health Checks and Troubleshooting
- Backup, Restore and Secret Rotation
- Administration, Audit and Diagnostics
- Configuration Reference
- Data Storage and Persistence
- Security Model and Hardening
Contribute