diff --git a/__pycache__/gopass.cpython-312.pyc b/__pycache__/gopass.cpython-312.pyc index 04322a5..991d52e 100644 Binary files a/__pycache__/gopass.cpython-312.pyc and b/__pycache__/gopass.cpython-312.pyc differ diff --git a/gopass.md b/gopass.md index 71c32f1..b23e38d 100644 --- a/gopass.md +++ b/gopass.md @@ -307,6 +307,17 @@ source /env.sh ``` then `gpgconf --reload gpg-agent`. It's a cache lifetime, not permanent — an agent restart (reboot/logout) clears it. + **Confirmed pitfall (2026-09-18): create this file with a plain shell + redirect** (`cat > "$GNUPGHOME/gpg-agent.conf" < --store bernina` errors oddly**: put diff --git a/gopass_bernina_setup.sh b/gopass_bernina_setup.sh index 121bb7e..ba951d0 100755 --- a/gopass_bernina_setup.sh +++ b/gopass_bernina_setup.sh @@ -348,8 +348,22 @@ fi echo echo "======================================================================" -echo "Add ONE line to this host's LOCAL ~/.bashrc (not shared - do this once" -echo "per host, or replace any older GNUPGHOME/GOPASS_HOMEDIR exports there)." +# ~/.bashrc itself may be force-copied (not symlinked) from this file on +# every login, with no diff check, per PSI's Partially Shared Home +# 'copy:' mechanism (~/network_drives/home/linux_home_links.yaml) - +# confirmed 2026-09-18. If so, an edit to ~/.bashrc directly would be +# silently lost at the next login, so point at the real source instead. +BASHRC_TEMPLATE="${HOME}/network_drives/home/linux_config/bashrc" +if [[ -f "${BASHRC_TEMPLATE}" ]]; then + echo "Add ONE line to ${BASHRC_TEMPLATE} - NOT to ~/.bashrc" + echo "directly: your ~/.bashrc here gets force-copied from that file on" + echo "every login with no diff check (see the 'copy:' section of" + echo "~/network_drives/home/linux_home_links.yaml), so a direct edit to" + echo "~/.bashrc would silently vanish at your next login." +else + echo "Add ONE line to this host's LOCAL ~/.bashrc (not shared - do this once" + echo "per host, or replace any older GNUPGHOME/GOPASS_HOMEDIR exports there)." +fi echo "Put it NEAR THE TOP - before any '[are we interactive?] || return'" echo "guard - so it also reaches non-interactive shells (VS Code Remote-SSH," echo "cron, some Jupyter kernels), which would otherwise silently fall back" @@ -359,9 +373,9 @@ echo " source ${ENV_FILE}" echo if [[ "${ALREADY_RECIPIENT}" -eq 1 ]]; then echo "You're already an authorized recipient of '${STORE_ALIAS}' (${EMAIL}) -" - echo "nothing else to do. Open a fresh shell (or source ~/.bashrc above)," - echo "then 'gopass show ${STORE_ALIAS}/...' should work (it'll ask for your" - echo "GPG passphrase once, then cache it)." + echo "nothing else to do. Open a fresh shell (so the line above takes" + echo "effect), then 'gopass show ${STORE_ALIAS}/...' should work (it'll" + echo "ask for your GPG passphrase once, then cache it)." else echo "One step only an existing recipient can do for you:" echo diff --git a/rhel9_onboarding.md b/rhel9_onboarding.md new file mode 100644 index 0000000..2dfd930 --- /dev/null +++ b/rhel9_onboarding.md @@ -0,0 +1,204 @@ +# RHEL9 Bernina console onboarding + +Step-by-step setup for a **new team member's first time** on the +Bernina RHEL9 consoles (`saresb-cons-*`, `saresb-vcons-*`). Do these in +order — later steps depend on earlier ones. Each step says what to run +and how to confirm it worked before moving on. + +If something doesn't match what's described here, check +[gopass.md](gopass.md) Troubleshooting and +[cheatsheet_admin.md](cheatsheet_admin.md) first — this doc gives you +the sequence, those give you the depth. + +## 0. Before you start (not self-service — central PSI IT) + +These have to be arranged for you; none of this is a script you can run +yourself. If any are missing, ask your supervisor/admin (currently +lemke_h) to get them fixed **before** continuing to step 1: + +- A PSI account (AD credentials). +- Console/login rights to the `saresb-cons-*`/`saresb-vcons-*` hosts (if + you can log in at all, this one's covered). +- Unix group membership — **check this yourself** once you're logged + in, don't just assume it's there: + ```bash + groups + ``` + Look for all three of: + - `unx-bernina` and `unx-sf_bernina` — general Bernina access. + - **`unx-sf_bernina_bs`** — needed later, for step 2 (the personal + directory). Without it, `create_personal_dir.sh` fails outright + with "Permission denied", and it's not something you can grant + yourself. + + If any are missing from the `groups` output, stop here and get that + sorted first — steps 1-3 below will behave oddly or fail in + confusing ways without them (e.g. step 2 failing isn't a bug to + troubleshoot, it's this). + +## 1. First login — let the automatic home setup run + +Log into any Bernina RHEL9 console normally (graphical login, not just +`ssh`). Two Puppet-managed services run automatically at login and set +up your shared home environment — you shouldn't need to touch them: + +- `mount-user-cifs-shares.service` mounts PSI's "Partially Shared Home" + at `~/network_drives` (same content on every PSI Linux host you log + into). +- `create-automatic-links-in-home.service` then applies your personal + `~/network_drives/home/linux_home_links.yaml`: most entries + (`.ssh/config`, `.ssh/id_ed25519*`, `.gitconfig`, `.condarc`, ...) are + plain **symlinks** into `~/network_drives/home/linux_config/`. + **`.bashrc` and `.ssh/authorized_keys` are different — they're real, + local files that get unconditionally overwritten (`copy:`, not + `link:`) from `~/network_drives/home/linux_config/{bashrc,ssh/authorized_keys}` + on *every single login*, no diff check.** (Deliberately not symlinks: + the shell/sshd need a real file the instant they start, before this + service — or even the mount — has necessarily finished.) + + > **This means: never hand-edit `~/.bashrc` directly.** Any local edit + > is silently discarded at your next login. If you ever need to + > change your `.bashrc` (this doc doesn't ask you to), edit + > `~/network_drives/home/linux_config/bashrc` instead — that's the + > actual source, and it's what every host you log into converges back + > to. + +**Verify it worked:** +```bash +ls ~/network_drives/home # should list files, not error +ls -la ~/.ssh # should show config/id_ed25519/... as symlinks, plus a local authorized_keys +``` + +**If `~/network_drives/home` doesn't exist / `ls` errors** (seen so far +specifically on virtual/VDI consoles, `saresb-vcons-*`): this almost +always means you don't have a Kerberos ticket yet in this session +(check with `klist` — no `krbtgt/...` line means no ticket). Fix, +**from a real interactive terminal** (not a script/non-interactive +shell): +```bash +setup-network-drives +``` +This checks for a ticket, prompts for your PSI password via `kinit` if +you don't have one yet, then mounts `network_drives`. Afterwards, +re-apply the symlinks without logging out: +```bash +/sf/bernina/bin/create-links-in-home +``` +Then re-check the `ls` commands above. + +## 2. Personal directory on `/sf/bernina/config/personal` + +This is real NFS storage (unlike the SMB-based `~/network_drives`), +needed for anything that can't live on SMB — e.g. git repos. Requires +`unx-sf_bernina_bs` group membership (step 0). + +```bash +/sf/bernina/bin/create_personal_dir.sh +``` + +What it does (safe to re-run): +- Makes sure `/sf/bernina/config/personal/` itself is group-writable + with the sticky bit set (`chmod 3775`) — like `/tmp`, anyone in + `unx-sf_bernina_bs` can add their own subdirectory, but nobody can + touch anyone else's. Only fixes this once, ever, for everyone. +- Creates your own `/sf/bernina/config/personal/`, locked to + `2700` — owner-only, nobody else can list or read into it even though + the parent directory is browsable. + +**Verify:** +```bash +ls -ld /sf/bernina/config/personal/$(whoami) # should show drwx--S--- owned by you +``` + +## 3. gopass shared secrets store + +The Bernina team shares credentials via `gopass` (GPG-encrypted, synced +through a private git repo on gitea.psi.ch). Full reference: +[gopass.md](gopass.md). + +### 3a. One-time prerequisite: a gitea.psi.ch account + registered SSH key + +You need a gitea.psi.ch account (log in there once via PSI SSO if you +don't have one yet) **before** running the setup script below — it +checks SSH auth to gitea and will stop and tell you to do this if it's +missing. + +1. If you don't already have an SSH key: the script below will offer to + generate one for you (`ssh-keygen -t ed25519`) — you can let it. +2. Add your public key (`~/.ssh/id_ed25519.pub`) at + `https://gitea.psi.ch` → Settings → SSH/GPG Keys → Add Key. +3. **Ask the admin (Henrik Lemke) to add you as a Collaborator (Write + access)** on the `Bernina/bernina-secrets` repo — needed to clone + the store in step 3b. (Message them directly, or via however your + team normally requests this.) + +### 3b. Run the setup script + +```bash +/sf/bernina/bin/gopass_bernina_setup.sh +``` + +Safe to re-run — every step checks current state first. It will: +- confirm/generate your SSH key and confirm gitea auth works, +- confirm/generate a personal GPG key (real name + PSI email, **set a + real passphrase** — there's no recovery if you forget it, only a + fresh key + re-authorization), +- clone the `bernina` store, +- write `~/network_drives/home/gopass/env.sh` and print a line to add + that sources it — **the script says to add it to your local + `~/.bashrc`, but per step 1's warning above, don't edit that file + directly: add it to `~/network_drives/home/linux_config/bashrc` + instead** (the file your local `.bashrc` gets force-copied from on + every login), otherwise it'll vanish at your next login. Put it near + the top (before any "non-interactive shell → return" guard) so gopass + also works from non-interactive tools (VS Code Remote-SSH, cron, + etc.), not just a plain terminal. +- export your GPG public key to + `~/network_drives/home/gopass/-gopass-pubkey.asc`. + +**Note:** you only need to run this once, on any *one* host. The GPG +key, gopass config, and store clone all live on +`~/network_drives/home/gopass/`, which is the same content on every +host you log into — nothing host-specific to redo elsewhere. + +### 3c. Send your public key to the admin + +At the end of the script's output, if you're not yet an authorized +recipient, it tells you exactly this: **send +`~/network_drives/home/gopass/-gopass-pubkey.asc` to the admin +(Henrik Lemke)** — internal email, Mattermost/Slack DM, or in person. +This is the actual secret-sharing gate: nobody can decrypt anything in +the store until their key is authorized this way, even after the repo +clone above succeeds. + +**What happens on the admin's end** (for your own understanding — not +something you do yourself): they run +```bash +gpg --import -gopass-pubkey.asc +gopass recipients add --store bernina +``` +which re-encrypts every existing secret for your key automatically. + +### 3d. Confirm it works + +Open a fresh terminal (so `~/.bashrc` picks up the `env.sh` line from +step 3b), then: +```bash +gopass mounts # should show 'bernina' with no error +gopass show bernina/... # pick any real entry; will ask for your GPG + # passphrase once, then cache it +``` +Until the admin has authorized your key (step 3c), `gopass show` will +fail with `not a recipient` — that's expected, not a bug. + +## Quick reference + +| Task | Script | +|---|---| +| Fix a missing/broken `~/network_drives` mount | `setup-network-drives` | +| Re-apply home symlinks without logging out | `/sf/bernina/bin/create-links-in-home` | +| Create/verify your personal NFS directory | `/sf/bernina/bin/create_personal_dir.sh` | +| Join the gopass secrets store | `/sf/bernina/bin/gopass_bernina_setup.sh` | +| Day-to-day gopass commands, troubleshooting | [gopass.md](gopass.md) | +| Keyboard shortcuts, general terminal tools | `cheatsheet` / `Super+F1` | +| Full admin/setup script reference | [cheatsheet_admin.md](cheatsheet_admin.md) |