From 9eea9782d118d3bade2a076e4aa59b022c5945c9 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 9 Oct 2026 00:26:25 +0200 Subject: [PATCH 1/4] chore(githooks): refresh post-commit/post-merge from the lib (fail-closed autopush read) --- .githooks/post-commit | 11 +++++++++-- .githooks/post-merge | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.githooks/post-commit b/.githooks/post-commit index 417fecf..08d9954 100755 --- a/.githooks/post-commit +++ b/.githooks/post-commit @@ -5,8 +5,15 @@ hook=post-commit # holds. Never fails the commit: no origin / offline / refused → warning only. # Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests). [ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0 -# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false -[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0 +# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed: +# an unparseable value or a config read failure also means "no push", named. +# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4. +v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$? +case "$rc:$v" in + 0:true|1:*) ;; + 0:false) exit 0 ;; + *) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;; +esac git remote get-url origin >/dev/null 2>&1 || exit 0 br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi diff --git a/.githooks/post-merge b/.githooks/post-merge index 69a9f65..853eda0 100755 --- a/.githooks/post-merge +++ b/.githooks/post-merge @@ -5,8 +5,15 @@ hook=post-merge # holds. Never fails the commit: no origin / offline / refused → warning only. # Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests). [ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0 -# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false -[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0 +# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed: +# an unparseable value or a config read failure also means "no push", named. +# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4. +v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$? +case "$rc:$v" in + 0:true|1:*) ;; + 0:false) exit 0 ;; + *) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;; +esac git remote get-url origin >/dev/null 2>&1 || exit 0 br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi From eb7a75182eb2b9f6c5a1a903fe409fa66ba2544a Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 9 Oct 2026 00:26:26 +0200 Subject: [PATCH 2/4] feat(install): offer rootless Docker at the end of the Linux install docker-ce-rootless-extras joins the Docker package list; offer_docker_rootless installs uidmap/dbus-user-session/slirp4netns, runs dockerd-rootless-setuptool.sh install (apt variant: /usr/bin, no PATH export) and enables linger. The rootful daemon is left alone. bashrc-linux exports DOCKER_HOST only when the user socket exists. README step 16 + package lists. --- .claude/tasks/TODO.md | 9 +++++++++ README.md | 9 +++++---- bash/bashrc-linux | 6 ++++++ install.sh | 27 ++++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 9037bd1..546e063 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -139,3 +139,12 @@ Port of the Alphalink dotfiles `repo` / `repo-reset` zsh functions, bash + zsh, ## Feature — gitflow.autopush asked at install, written to ~/.gitconfig (2026-10-07) Branch: feature/gitconfig-autopush (off develop). Plan: .claude/tasks/plans/2026-10-07-gitconfig-autopush-1734.md - [ ] /feat run: gitconfig `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath`; install.sh `resolve_autopush` (exact true/false: existing ~/.gitconfig value via sed → DOTFILES_GITFLOW_AUTOPUSH (bad value aborts) → prompt re-asks → true), deploy_gitconfig takes name/email/autopush (fixes `name = @USER@` deployed from the template path) + fail-closed leak check; README/CLAUDE.md; oracle harness .claude/tasks/contracts/check-autopush-render.sh + +## Feature — Docker rootless offered at install (2026-10-09) +Branch: feature/docker-rootless (off develop). Mirrors the manual setup done on this machine +(docs.docker.com/engine/security/rootless, apt variant: setuptool lives in /usr/bin, not ~/bin). +- [x] install.sh: `docker-ce-rootless-extras` in the install_docker package list +- [x] install.sh: offer_docker_rootless() — uidmap/dbus-user-session/slirp4netns + extras, setuptool install (no --force), enable-linger; rootful daemon left as is +- [x] bash/bashrc-linux: DOCKER_HOST exported only when the rootless socket exists (no PATH line: /usr/bin already on PATH) +- [x] README.md: table row, step 2 packages, packages list, new offer step +- [x] shellcheck + bash -n; commit on the feature branch. No finish without explicit signal. diff --git a/README.md b/README.md index a4b534e..258914e 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install. | Path | Purpose | | -------------------- | -------------------------------------------------------------- | -| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering three extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | +| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. | | `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on both OSes to `~/.config/tmux/tmux.conf` (tmux ≥ 3.1). | | `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer, offered `[y/N]` at the end of a Linux install). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. | | `etc/tmpfiles.d/tmp.conf` | Cleanup rules for a disk-backed `/tmp` (wiped at boot, 10-day purge). Deployed by the `/tmp` on disk offer. | @@ -63,7 +63,7 @@ No argument — the OS is auto-detected. What it does: 1. On Debian/Ubuntu, installs a set of CLI/dev packages via `apt-get` (see below). On macOS, Homebrew does it instead: see [macOS](#macos). -2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin — skipped if `docker` is already present. +2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin + rootless extras — skipped if `docker` is already present. 3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`. 4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`. 5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`. @@ -77,6 +77,7 @@ What it does: 13. On Linux, installs the **security baseline**, always, no prompt: **fail2ban** (+ `nftables`) with `etc/fail2ban/jail.d/local.conf` (sshd jail reading the journal, bans the offending IP on every port so the SSH port does not matter, 5 failures in 10 min → 1 h ban, loopback and private LAN ranges never banned); **unattended-upgrades** enabled through `etc/apt/apt.conf.d/20auto-upgrades`; and the **sshd drop-in** `etc/ssh/sshd_config.d/20-hardening.conf` (`PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`), checked with `sshd -t` and removed again if sshd rejects it, then `reload ssh`. Authentication methods, port and user lists are left as they are. 14. On Linux, at the very end, **offers** (`[y/N]`, skipped when no terminal is attached) to move **`/tmp` to disk**: Ubuntu mounts `/tmp` as a RAM-backed tmpfs capped at 50% of RAM, which agent runs fill, halving the RAM and breaking every shell with "No space left on device". Accepting masks `tmp.mount` and installs `etc/tmpfiles.d/tmp.conf` (wipe at boot, 10-day purge). Effective at the next reboot. 15. On Linux, at the very end, **offers** to keep **SSH reachable under memory pressure**: installs the `ssh.service` drop-in (`OOMScoreAdjust=-1000`, `MemoryMin=256M`) and `earlyoom` with `etc/default/earlyoom` (kills the largest process, `node`/`java` first and never `sshd`, once free RAM and swap both drop under 10%). Restarting `ssh` keeps open sessions. Note: `MemoryMin` protects the sshd daemon only; login sessions live in `user.slice`, so no setting can reserve RAM for a future shell. earlyoom acting in time is the real protection. +16. On Linux, at the very end, **offers** to set up **rootless Docker**: installs `uidmap dbus-user-session slirp4netns docker-ce-rootless-extras`, runs `dockerd-rootless-setuptool.sh install` as you (the apt package puts it in `/usr/bin`, so no `PATH` line is needed, unlike the `~/bin` install from `get.docker.com/rootless`), then `loginctl enable-linger` so the user daemon starts at boot. The tool creates `~/.config/systemd/user/docker.service` and switches the CLI to the `rootless` context; the deployed bashrc exports `DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock` whenever that socket exists, for tools that ignore contexts. The rootful daemon is not touched: both coexist, but the tool refuses to run while `/var/run/docker.sock` is writable by your user (docker group), in which case disable it first (`sudo systemctl disable --now docker.service docker.socket`). Needs `/etc/subuid` and `/etc/subgid` entries for the user (Ubuntu adds them at user creation). ### Packages installed (apt) @@ -86,12 +87,12 @@ What it does: - **Runtimes**: `nodejs python3-pip pipx php-cli` - **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP) - **Media / doc CLI**: `ffmpeg weasyprint poppler-utils qpdf webp libavif-bin` -- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin` (via Docker's repo) +- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras` (via Docker's repo) - **Desktop / GPU**: `ubuntu-desktop-minimal` (always, Linux) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected) - **Remote access**: `gnome-remote-desktop openssl` (apt) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code - **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`) - **Security baseline (Linux, always)**: `fail2ban nftables unattended-upgrades` -- **Optional (end-of-install offer, Linux)**: `earlyoom` +- **Optional (end-of-install offer, Linux)**: `earlyoom`; `uidmap dbus-user-session slirp4netns` (rootless Docker) The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup), re-clones plugins, skips Docker if already installed, and re-deploys the `bin/` scripts. diff --git a/bash/bashrc-linux b/bash/bashrc-linux index ec41d34..af10fd1 100644 --- a/bash/bashrc-linux +++ b/bash/bashrc-linux @@ -16,6 +16,12 @@ case ":$PATH:" in *) export PATH="$HOME/.local/bin:$PATH" ;; esac +# Rootless Docker (install.sh offer): tools that ignore the CLI context (docker-py, +# testcontainers...) need DOCKER_HOST; only set when the user daemon's socket exists. +if [ -S "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock" ]; then + export DOCKER_HOST="unix://${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock" +fi + # Set history size to unlimited if [[ $EUID == 0 ]] ; then export HISTSIZE=0 diff --git a/install.sh b/install.sh index 4b2b13c..28b544b 100755 --- a/install.sh +++ b/install.sh @@ -30,7 +30,8 @@ install_docker() { echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${codename} stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null sudo apt-get update - sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin + sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin \ + docker-compose-plugin docker-ce-rootless-extras } # NVIDIA driver: only when an NVIDIA GPU is on the PCI bus (vendor id 10de), so the @@ -166,6 +167,29 @@ offer_cloudpex() { bash "$SCRIPT_DIR/cloudpex/install.sh" } +# Rootless Docker, on request: a second daemon running as the login user (no root, +# no docker group), the docs' apt variant. docker-ce-rootless-extras ships +# dockerd-rootless-setuptool.sh in /usr/bin, so the PATH export the docs mention is +# not needed (that line is for the ~/bin install from get.docker.com/rootless). The +# setup tool writes ~/.config/systemd/user/docker.service, starts it and switches the +# CLI to the "rootless" context; linger keeps the daemon up without a login session. +# The rootful daemon is left as it is: the two coexist (the tool only refuses when +# /var/run/docker.sock is writable by the user, i.e. docker group membership). +# Idempotent: apt and the tool both skip what exists. Ubuntu-only (Docker apt repo). +offer_docker_rootless() { + confirm "Set up rootless Docker for $(id -un) (daemon runs as your user)?" || return 0 + if ! sudo apt-get install -y uidmap dbus-user-session slirp4netns docker-ce-rootless-extras; then + echo "docker-ce-rootless-extras not installable (Docker apt repo missing?) — skipping" >&2 + return 0 + fi + if ! dockerd-rootless-setuptool.sh install; then + echo "rootless Docker setup failed — see the tool's output above, rootful Docker unchanged" >&2 + return 0 + fi + sudo loginctl enable-linger "$(id -un)" + echo "Rootless Docker ready: CLI context 'rootless' selected; the bashrc exports DOCKER_HOST when its socket exists." +} + # fail2ban: bans an IP on every port after repeated SSH failures. The sshd jail # reads the journal (works with or without /var/log/auth.log) and bans all ports, # so the port sshd listens on does not matter — the previous server's jail only @@ -776,6 +800,7 @@ if command -v apt-get >/dev/null 2>&1; then offer_tmp_on_disk offer_ssh_memory_guard offer_cloudpex + offer_docker_rootless fi # macOS: login shells skip ~/.bashrc unless ~/.bash_profile sources it (kept even From 6882aa7c146d1716e12f0a6a33d50367107a3f2e Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 9 Oct 2026 00:26:26 +0200 Subject: [PATCH 3/4] =?UTF-8?q?chore(memory):=20journal=20=E2=80=94=20feat?= =?UTF-8?q?=20docker-rootless?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/memory/journal.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index 4518866..cf73e6c 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -123,3 +123,6 @@ Done: choose_macos_shell default bash → zsh (Enter, no tty, unknown value). Fo ## 2026-10-07 (3) — gitflow.autopush asked at install, hooksPath fixed, identity bug Done: `gitconfig` template `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath = ~/.claude/githooks`; install.sh `resolve_autopush` (existing ~/.gitconfig value via sed → `DOTFILES_GITFLOW_AUTOPUSH` strict, bad value aborts → prompt re-asks exact true/false, Enter = true → true), `render_gitconfig` fail-closed (non-boolean / leaked placeholder = nothing written). Found by challenge: install.sh:688 passed the repo bashrc TEMPLATE to deploy_gitconfig → every install wrote `name = @USER@`; fixed, identity passed directly. `shopt -u patsub_replacement` (bash ≥ 5.2 `&` in names). Oracle harness `.claude/tasks/contracts/check-autopush-render.sh` (12 cases, scratch HOMEs, zero `git config`: that command family is denied to the session). 3 challengers + 1 confirm, verifier ECARTS(1) → CONFORME, security PASS (MEDIUM noted: newline in IDENTITY_* env injects gitconfig lines, pre-existing for rc too). Code commit 9901ec5 on feature/gitconfig-autopush; merge on user signal. + +## 2026-10-09 — rootless Docker offered at install +Done: `offer_docker_rootless()` (uidmap/dbus-user-session/slirp4netns/docker-ce-rootless-extras, `dockerd-rootless-setuptool.sh install` no --force, enable-linger, rootful daemon untouched), extras in install_docker list, bashrc-linux exports DOCKER_HOST only when the user socket exists (no PATH line: apt variant puts the tool in /usr/bin, not ~/bin). README step 16. Stub harness 4 cases + snippet with/without socket OK, shellcheck clean. Branch feature/docker-rootless, not merged. Machine state: rootless already set up by hand, rootful daemon still enabled, ~/.bashrc has a hardcoded uid 1000 DOCKER_HOST line (redeploy replaces it). From de6fa1659c231bcf46c74130b428801ee7eb5df6 Mon Sep 17 00:00:00 2001 From: bchanot Date: Fri, 9 Oct 2026 00:28:51 +0200 Subject: [PATCH 4/4] feat(install): rootless Docker offer disables the rootful daemon first docker.service + docker.socket disabled and /var/run/docker.sock removed before dockerd-rootless-setuptool.sh install, as the docs recommend; skipped when no rootful unit exists. --- .claude/memory/journal.md | 2 +- .claude/tasks/TODO.md | 2 +- README.md | 2 +- install.sh | 11 ++++++++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.claude/memory/journal.md b/.claude/memory/journal.md index cf73e6c..01ce8d0 100644 --- a/.claude/memory/journal.md +++ b/.claude/memory/journal.md @@ -125,4 +125,4 @@ Done: choose_macos_shell default bash → zsh (Enter, no tty, unknown value). Fo Done: `gitconfig` template `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath = ~/.claude/githooks`; install.sh `resolve_autopush` (existing ~/.gitconfig value via sed → `DOTFILES_GITFLOW_AUTOPUSH` strict, bad value aborts → prompt re-asks exact true/false, Enter = true → true), `render_gitconfig` fail-closed (non-boolean / leaked placeholder = nothing written). Found by challenge: install.sh:688 passed the repo bashrc TEMPLATE to deploy_gitconfig → every install wrote `name = @USER@`; fixed, identity passed directly. `shopt -u patsub_replacement` (bash ≥ 5.2 `&` in names). Oracle harness `.claude/tasks/contracts/check-autopush-render.sh` (12 cases, scratch HOMEs, zero `git config`: that command family is denied to the session). 3 challengers + 1 confirm, verifier ECARTS(1) → CONFORME, security PASS (MEDIUM noted: newline in IDENTITY_* env injects gitconfig lines, pre-existing for rc too). Code commit 9901ec5 on feature/gitconfig-autopush; merge on user signal. ## 2026-10-09 — rootless Docker offered at install -Done: `offer_docker_rootless()` (uidmap/dbus-user-session/slirp4netns/docker-ce-rootless-extras, `dockerd-rootless-setuptool.sh install` no --force, enable-linger, rootful daemon untouched), extras in install_docker list, bashrc-linux exports DOCKER_HOST only when the user socket exists (no PATH line: apt variant puts the tool in /usr/bin, not ~/bin). README step 16. Stub harness 4 cases + snippet with/without socket OK, shellcheck clean. Branch feature/docker-rootless, not merged. Machine state: rootless already set up by hand, rootful daemon still enabled, ~/.bashrc has a hardcoded uid 1000 DOCKER_HOST line (redeploy replaces it). +Done: `offer_docker_rootless()` (uidmap/dbus-user-session/slirp4netns/docker-ce-rootless-extras, `dockerd-rootless-setuptool.sh install` no --force, enable-linger, rootful daemon disabled first as the docs recommend, user asked for it), extras in install_docker list, bashrc-linux exports DOCKER_HOST only when the user socket exists (no PATH line: apt variant puts the tool in /usr/bin, not ~/bin). README step 16. Stub harness 4 cases + snippet with/without socket OK, shellcheck clean. Branch feature/docker-rootless, not merged. Machine state: rootless already set up by hand, rootful daemon still enabled, ~/.bashrc has a hardcoded uid 1000 DOCKER_HOST line (redeploy replaces it). diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 546e063..cf0a984 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -144,7 +144,7 @@ Branch: feature/gitconfig-autopush (off develop). Plan: .claude/tasks/plans/2026 Branch: feature/docker-rootless (off develop). Mirrors the manual setup done on this machine (docs.docker.com/engine/security/rootless, apt variant: setuptool lives in /usr/bin, not ~/bin). - [x] install.sh: `docker-ce-rootless-extras` in the install_docker package list -- [x] install.sh: offer_docker_rootless() — uidmap/dbus-user-session/slirp4netns + extras, setuptool install (no --force), enable-linger; rootful daemon left as is +- [x] install.sh: offer_docker_rootless() — uidmap/dbus-user-session/slirp4netns + extras, setuptool install (no --force), enable-linger; rootful daemon disabled first - [x] bash/bashrc-linux: DOCKER_HOST exported only when the rootless socket exists (no PATH line: /usr/bin already on PATH) - [x] README.md: table row, step 2 packages, packages list, new offer step - [x] shellcheck + bash -n; commit on the feature branch. No finish without explicit signal. diff --git a/README.md b/README.md index 258914e..d55837a 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ What it does: 13. On Linux, installs the **security baseline**, always, no prompt: **fail2ban** (+ `nftables`) with `etc/fail2ban/jail.d/local.conf` (sshd jail reading the journal, bans the offending IP on every port so the SSH port does not matter, 5 failures in 10 min → 1 h ban, loopback and private LAN ranges never banned); **unattended-upgrades** enabled through `etc/apt/apt.conf.d/20auto-upgrades`; and the **sshd drop-in** `etc/ssh/sshd_config.d/20-hardening.conf` (`PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`), checked with `sshd -t` and removed again if sshd rejects it, then `reload ssh`. Authentication methods, port and user lists are left as they are. 14. On Linux, at the very end, **offers** (`[y/N]`, skipped when no terminal is attached) to move **`/tmp` to disk**: Ubuntu mounts `/tmp` as a RAM-backed tmpfs capped at 50% of RAM, which agent runs fill, halving the RAM and breaking every shell with "No space left on device". Accepting masks `tmp.mount` and installs `etc/tmpfiles.d/tmp.conf` (wipe at boot, 10-day purge). Effective at the next reboot. 15. On Linux, at the very end, **offers** to keep **SSH reachable under memory pressure**: installs the `ssh.service` drop-in (`OOMScoreAdjust=-1000`, `MemoryMin=256M`) and `earlyoom` with `etc/default/earlyoom` (kills the largest process, `node`/`java` first and never `sshd`, once free RAM and swap both drop under 10%). Restarting `ssh` keeps open sessions. Note: `MemoryMin` protects the sshd daemon only; login sessions live in `user.slice`, so no setting can reserve RAM for a future shell. earlyoom acting in time is the real protection. -16. On Linux, at the very end, **offers** to set up **rootless Docker**: installs `uidmap dbus-user-session slirp4netns docker-ce-rootless-extras`, runs `dockerd-rootless-setuptool.sh install` as you (the apt package puts it in `/usr/bin`, so no `PATH` line is needed, unlike the `~/bin` install from `get.docker.com/rootless`), then `loginctl enable-linger` so the user daemon starts at boot. The tool creates `~/.config/systemd/user/docker.service` and switches the CLI to the `rootless` context; the deployed bashrc exports `DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock` whenever that socket exists, for tools that ignore contexts. The rootful daemon is not touched: both coexist, but the tool refuses to run while `/var/run/docker.sock` is writable by your user (docker group), in which case disable it first (`sudo systemctl disable --now docker.service docker.socket`). Needs `/etc/subuid` and `/etc/subgid` entries for the user (Ubuntu adds them at user creation). +16. On Linux, at the very end, **offers** to set up **rootless Docker**: installs `uidmap dbus-user-session slirp4netns docker-ce-rootless-extras`, runs `dockerd-rootless-setuptool.sh install` as you (the apt package puts it in `/usr/bin`, so no `PATH` line is needed, unlike the `~/bin` install from `get.docker.com/rootless`), then `loginctl enable-linger` so the user daemon starts at boot. The tool creates `~/.config/systemd/user/docker.service` and switches the CLI to the `rootless` context; the deployed bashrc exports `DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock` whenever that socket exists, for tools that ignore contexts. The rootful daemon is disabled first (`systemctl disable --now docker.service docker.socket`, socket removed), as the docs recommend: `docker` then only talks to your user daemon. Needs `/etc/subuid` and `/etc/subgid` entries for the user (Ubuntu adds them at user creation). ### Packages installed (apt) diff --git a/install.sh b/install.sh index 28b544b..acf070c 100755 --- a/install.sh +++ b/install.sh @@ -173,8 +173,8 @@ offer_cloudpex() { # not needed (that line is for the ~/bin install from get.docker.com/rootless). The # setup tool writes ~/.config/systemd/user/docker.service, starts it and switches the # CLI to the "rootless" context; linger keeps the daemon up without a login session. -# The rootful daemon is left as it is: the two coexist (the tool only refuses when -# /var/run/docker.sock is writable by the user, i.e. docker group membership). +# The rootful daemon is disabled first, as the docs recommend: one daemon, and the +# tool refuses to run while /var/run/docker.sock is writable by the user anyway. # Idempotent: apt and the tool both skip what exists. Ubuntu-only (Docker apt repo). offer_docker_rootless() { confirm "Set up rootless Docker for $(id -un) (daemon runs as your user)?" || return 0 @@ -182,8 +182,13 @@ offer_docker_rootless() { echo "docker-ce-rootless-extras not installable (Docker apt repo missing?) — skipping" >&2 return 0 fi + if systemctl cat docker.service >/dev/null 2>&1; then + echo "Disabling the rootful Docker daemon (docker.service, docker.socket)" + sudo systemctl disable --now docker.service docker.socket + sudo rm -f /var/run/docker.sock + fi if ! dockerd-rootless-setuptool.sh install; then - echo "rootless Docker setup failed — see the tool's output above, rootful Docker unchanged" >&2 + echo "rootless Docker setup failed — see the tool's output above (rootful daemon is disabled)" >&2 return 0 fi sudo loginctl enable-linger "$(id -un)"