diff --git a/deploy/panel_installer/engine.py b/deploy/panel_installer/engine.py
index b41ef3d..335d6ea 100644
--- a/deploy/panel_installer/engine.py
+++ b/deploy/panel_installer/engine.py
@@ -348,6 +348,7 @@ class Installer:
self.heartbeat = heartbeat
self.scopes = scopes or {}
self.state_file = STATE / "installation.json"
+ self.folder_sftp_supported = False
self.php, self.modern_mail = platform_settings()
with (SOURCE / "pyproject.toml").open("rb") as project:
self.release = tomllib.load(project)["project"]["version"]
@@ -451,7 +452,7 @@ class Installer:
def packages(self):
packages = list(BASE_PACKAGES)
if self.php:
- packages.append(f"php{self.php}-fpm")
+ packages.extend((f"php{self.php}-fpm", "openssh-server"))
if self.plan.dns.mode == "local":
packages.extend(("bind9", "bind9-utils"))
if self.plan.mail.mode == "local":
@@ -664,7 +665,12 @@ class Installer:
COULOBRE_WEB_FILE_MANAGER="1",
COULOBRE_WEBSITE_JOBS="1",
COULOBRE_LOCAL_ACCOUNT_BACKUPS="1",
+ COULOBRE_LOCAL_WEB_SFTP="1",
)
+ if self.folder_sftp_supported:
+ options["COULOBRE_LOCAL_FOLDER_SFTP"] = "1"
+ if self.plan.access != "proxy":
+ options["COULOBRE_SFTP_HOST"] = self.plan.hostname
if self.plan.access == "acme":
options["COULOBRE_LOCAL_WEB_HTTPS"] = "1"
if self.plan.dns.mode != "off":
@@ -917,19 +923,33 @@ class Installer:
label="Enable website usage logging",
)
workers.append("coulobre-website-usage.socket")
- features = ["website-files", "website-jobs", "account-backups"]
+ features = [
+ "website-files",
+ "website-jobs",
+ "account-backups",
+ "website-sftp",
+ "folder-sftp",
+ ]
if self.plan.access == "acme":
features.append("website-https")
- workers.extend(
- run(
- BINDIR / "python",
- "-m",
- "coulobre.local_feature_setup",
- ASSETS,
- *features,
- label="Configure local hosting tools",
- ).splitlines()
+ local_workers = run(
+ BINDIR / "python",
+ "-m",
+ "coulobre.local_feature_setup",
+ "--skip-unsupported-folder-sftp",
+ ASSETS,
+ *features,
+ label="Configure local hosting tools",
+ ).splitlines()
+ workers.extend(local_workers)
+ self.folder_sftp_supported = (
+ "coulobre-folder-sftp.socket" in local_workers
)
+ if not self.folder_sftp_supported:
+ self.progress(
+ "Folder SFTP needs a filesystem with ID-mapped mount "
+ "support. Website SFTP is available."
+ )
for name in ("dns", "mail"):
target = getattr(self.plan, name)
if target.mode != "off":
diff --git a/docs/deployment.md b/docs/deployment.md
index 945772f..b215f74 100644
--- a/docs/deployment.md
+++ b/docs/deployment.md
@@ -1541,6 +1541,14 @@ that certificate. Certbot renews it with its saved authenticator.
## Set up SFTP access for hosted websites
+Supported full-service installs configure key-based SFTP. On an existing
+installer-managed panel, open **Operator Settings → Server** to enable
+website SFTP and folder-scoped logins. Set `COULOBRE_SFTP_HOST` and
+`COULOBRE_SFTP_PORT` in `/etc/coulobre/panel.env` when customers connect to a
+different host or port. The panel displays these values in **SFTP Users**.
+
+For a manual installation, configure OpenSSH and the worker directly.
+
Use OpenSSH on the local web node. The site account starts in `/public`
inside its hosting directory. OpenSSH allows public key authentication
and restricts the connection to file transfers.
diff --git a/src/coulobre/hosting/folder_sftp_views.py b/src/coulobre/hosting/folder_sftp_views.py
index 909617a..1aafdf3 100644
--- a/src/coulobre/hosting/folder_sftp_views.py
+++ b/src/coulobre/hosting/folder_sftp_views.py
@@ -11,6 +11,7 @@ from coulobre.sftp_keys import normalize_public_keys
from coulobre.website_files import directory_parts
from .access import customer_for_user
+from .installation_features import panel_feature_allowed
from .models import FolderSftpLogin, HostingAccount
from .resource_requests import (
lock_hosting_account,
@@ -119,12 +120,16 @@ def folder_sftp_users(request, pk):
initial={"public_keys": login.public_keys} if edit else {},
)
enabled = settings.LOCAL_FOLDER_SFTP
+ accepts_keys = panel_feature_allowed(
+ "LOCAL_WEB_SFTP"
+ ) and panel_feature_allowed("LOCAL_FOLDER_SFTP")
problem = ""
if request.method == "POST":
if (
not enabled
or action not in {"create", "keys", "remove"}
or ((action != "create") != edit)
+ or (action != "remove" and not accepts_keys)
):
raise Http404
if action == "remove" or form.is_valid():
@@ -150,7 +155,10 @@ def folder_sftp_users(request, pk):
"form": form,
"login": login,
"enabled": enabled,
+ "accepts_keys": accepts_keys,
"logins": account.folder_sftp_logins.order_by("label"),
"problem": problem,
+ "sftp_host": settings.SFTP_HOST,
+ "sftp_port": settings.SFTP_PORT,
},
)
diff --git a/src/coulobre/hosting/installation_features.py b/src/coulobre/hosting/installation_features.py
index 8437857..7d6160b 100644
--- a/src/coulobre/hosting/installation_features.py
+++ b/src/coulobre/hosting/installation_features.py
@@ -107,6 +107,22 @@ FEATURES = (
"Install the task worker and allow tasks in the hosting package.",
"coulobre-website-jobs",
),
+ Feature(
+ "LOCAL_WEB_SFTP",
+ "Website SFTP access",
+ "OpenSSH Server and the website SFTP worker",
+ "set-up-sftp-access-for-hosted-websites",
+ "Check OpenSSH Server and enable the website SFTP worker.",
+ "coulobre-sftp-apply",
+ ),
+ Feature(
+ "LOCAL_FOLDER_SFTP",
+ "Folder-scoped SFTP accounts",
+ "Website SFTP access and ID-mapped mounts",
+ "enable-folder-scoped-sftp-logins",
+ "Enable website SFTP and check the filesystem for ID-mapped mounts.",
+ "coulobre-folder-sftp",
+ ),
Feature(
"LOCAL_DNS_PUBLISHING",
"DNS publishing",
diff --git a/src/coulobre/hosting/installation_views.py b/src/coulobre/hosting/installation_views.py
index 7ddaca5..3c0b125 100644
--- a/src/coulobre/hosting/installation_views.py
+++ b/src/coulobre/hosting/installation_views.py
@@ -68,6 +68,8 @@ OPERATOR_FEATURE_SECTIONS = {
"LOCAL_WEB_ACTIVATION",
"WEB_FILE_MANAGER",
"WEBSITE_JOBS",
+ "LOCAL_WEB_SFTP",
+ "LOCAL_FOLDER_SFTP",
"LOCAL_DNS_PUBLISHING",
"DEFAULT_DNS_ZONES",
),
@@ -251,6 +253,7 @@ class FeatureConfigurationView(UserPassesTestMixin, FormView):
key != "account-backups"
or settings.LOCAL_DATABASE_PROVISIONING
)
+ and (key != "folder-sftp" or settings.LOCAL_WEB_SFTP)
}
def post(self, request, *args, **kwargs):
diff --git a/src/coulobre/hosting/templates/hosting/folder_sftp_users.html b/src/coulobre/hosting/templates/hosting/folder_sftp_users.html
index c6a461d..1b16332 100644
--- a/src/coulobre/hosting/templates/hosting/folder_sftp_users.html
+++ b/src/coulobre/hosting/templates/hosting/folder_sftp_users.html
@@ -9,13 +9,14 @@
Access to the hosting account, including files in Primary hosting login
/backups.
Connect to {% if sftp_host %}{{ sftp_host }}{% else %}your web node's SSH hostname{% endif %} on port {{ sftp_port }} with the username shown for each login.
| Folder login | Website folder | State | Actions |
|---|---|---|---|
{{ entry.label }}{{ entry.spec.username }} | {{ entry.folder|default:"Entire website" }} | {{ entry.state|capfirst }}{% if entry.problem %} {{ entry.problem }} {% endif %} |
{% if enabled and entry.finished_at %} - Manage keys + {% if accepts_keys %}Manage keys{% endif %} @@ -23,9 +24,10 @@ |
| No folder logins. | |||
Generate a key on your computer with ssh-keygen -t ed25519. Paste the contents of the .pub file here and keep the private key on your computer.
New folder access and key changes are paused.
{% else %}Folder logins require the scoped SFTP worker on the web server.
{% endif %} {% endblock %} diff --git a/src/coulobre/hosting/templates/hosting/sftp_keys.html b/src/coulobre/hosting/templates/hosting/sftp_keys.html index 775b3cd..4fe8a4f 100644 --- a/src/coulobre/hosting/templates/hosting/sftp_keys.html +++ b/src/coulobre/hosting/templates/hosting/sftp_keys.html @@ -35,7 +35,7 @@Run this command on your computer.
ssh-keygen -t ed25519
Choose a passphrase when prompted. Use a different filename if you already have a key. With the default filename, upload ~/.ssh/id_ed25519.pub. Keep the private key on your computer.
Use the web node's SSH hostname and port with the username coulobre-{{ account.pk }}. The SFTP session starts in /public.
Connect as coulobre-{{ account.pk }} on {% if sftp_host %}{{ sftp_host }}{% else %}your web node's SSH hostname{% endif %}, port {{ sftp_port }}. The SFTP session starts in /public.