]> vilimpoc.org git repositories - dotfiles/blob - README.md
dotfiles: install the rsync release's ssh.exe beside rsync.exe
[dotfiles] / README.md
1 # dotfiles
2
3 Windows development-box provisioning scripts.
4
5 `setup-windows.bat` takes a fresh Windows install to a working C++ / native
6 development environment: editors and shells, Python, the Visual Studio 2022
7 toolchain (including the Clang and Windows XP targeting toolsets), the Windows
8 Driver Kit, and a handful of analysis tools (Sysinternals, OpenCppCoverage,
9 BinSkim, the Windows Performance Toolkit). It also sets the box up to be driven
10 remotely: OpenSSH Server plus an rsync build for Windows, which is what makes a
11 throwaway VM reachable from a Linux host.
12
13 ## Files
14
15 | File | Purpose |
16 | --- | --- |
17 | `setup-windows.bat` | Entry point. Runs the winget installs, then the non-elevated script, then launches the elevated half and prints its log. |
18 | `setup-windows-no-uac.ps1` | The non-elevated, per-user half: WinMerge and BinSkim on the user `PATH`, and the global git config (identity, plus `core.sshCommand`). Can also be run directly from an ordinary prompt. |
19 | `setup-windows-with-uac.ps1` | The elevated half, started via UAC by the batch file. Enables `ssh-agent`, installs the OpenSSH Client and Server capabilities and starts `sshd`, unpacks the `rsync-windows` release zip for this architecture (`rsync.exe` plus the `ssh.exe` it runs) into `C:\Tools\rsync` on the machine `PATH`, then installs Visual Studio 2022 Community with the required components, the WDK, and the Windows Performance Toolkit. Can also be run directly from an Administrator prompt. |
20
21 ## Usage
22
23 1. **Edit `setup-windows-no-uac.ps1` first.** The global git identity near the
24    top of the file is empty:
25
26    ```powershell
27    $GitUserName  = ''   # e.g. 'Ada Lovelace'
28    $GitUserEmail = ''   # e.g. 'ada@example.com'
29    ```
30
31    Fill in your own name and email, or leave them empty to keep your identity
32    per-repository - the script skips `user.name` / `user.email` rather than
33    writing a placeholder, and says so. Everything else in that script is set
34    either way.
35
36 2. Run it from a normal (non-elevated) prompt:
37
38    ```bat
39    setup-windows.bat
40    ```
41
42    It will raise a single UAC prompt for the elevated half. Accept it — declining
43    leaves Visual Studio and the WDK uninstalled, and the script says so.
44
45 3. Restart your shell afterwards so the updated user `PATH` is picked up, and
46    reboot if a step reported that a restart was required.
47
48 ## Notes
49
50 - The elevated half writes a transcript to `setup-windows-uac.log` next to the
51   script; the batch file prints it when the elevated window closes. The log is
52   gitignored, as it contains local paths.
53 - **git uses the Windows SSH client.** `setup-windows-no-uac.ps1` sets
54   `core.sshCommand` to `%WINDIR%/System32/OpenSSH/ssh.exe`. Git for Windows
55   otherwise prefers its own bundled MSYS2 `ssh.exe`, which cannot reach the
56   Windows `ssh-agent` service that the elevated half enables - Win32-OpenSSH
57   publishes the agent on a named pipe the MSYS2 build does not speak. Without
58   this, keys loaded with `ssh-add` from PowerShell are invisible to `git`, and a
59   push falls back to hunting for a key file and prompting for its passphrase.
60   The value uses forward slashes on purpose: git parses `core.sshCommand` with
61   shell quoting rules, in which a backslash is an escape character.
62 - All three scripts are idempotent — re-running skips anything already installed.
63   BinSkim in particular checks NuGet for the newest stable version *before*
64   downloading: the package is a self-contained .NET build well over 100 MB, and
65   re-provisioning an up-to-date box should not pay for it. The installed version
66   is tracked in `nupkg-version.txt` beside the tool.
67 - `setup-windows-no-uac.ps1` runs its steps independently: one failing warns and
68   the rest still run, and it exits 1 if any did. The `.bat` reports that and
69   carries on to the elevated half, which is the part worth the UAC prompt. Use
70   `-Skip` to re-run a subset, e.g. `.\setup-windows-no-uac.ps1 -Skip BinSkim`.
71   Run it **non-elevated**: it writes per-user state (the `HKCU` `PATH`, the
72   `.gitconfig` under `%USERPROFILE%`), so an elevated run would configure the
73   administrator's profile instead. It warns if you do.
74 - **Remote access.** OpenSSH Server is installed from the Windows on-demand
75   capability (10/1809+), set to start automatically, and given an inbound TCP 22
76   firewall rule on *all* profiles — a VM's host-only or bridged adapter is
77   routinely classified Public, which is the usual reason a running `sshd` is
78   unreachable. Windows ships no `rsync`, so a build of it
79   ([nuket/rsync-windows](https://github.com/nuket/rsync-windows)) is installed to
80   `C:\Tools\rsync` and added to the **machine** `PATH`. That last detail matters:
81   the remote end of an `rsync` runs non-interactively, with no login shell, and
82   Win32-OpenSSH builds that environment from the registry `PATH` rather than from
83   a profile. Key auth needs `~/.ssh/authorized_keys` ACL'd to just you and
84   `SYSTEM`; accounts in the Administrators group use
85   `C:\ProgramData\ssh\administrators_authorized_keys` instead.
86 - **rsync brings its own `ssh.exe`.** That release ships as one zip per
87   architecture — `rsync-windows-x64.zip` / `rsync-windows-x86.zip`, each holding
88   `rsync.exe`, an `ssh.exe`, `COPYING.txt` and `NOTICE-ssh.txt` — and the
89   elevated half picks the zip for the OS bitness, verifies it against the
90   published `.sha256`, and unpacks the pair together. Together is the point:
91   `rsync.exe` prefers an `ssh.exe` sitting in its own directory, and the release
92   builds one because the client Windows ships reads its stdin 3 KB at a time,
93   which holds a transfer *from* the box at ~17 MB/s however fast the link is.
94   Nothing else about it differs — same `~/.ssh`, same `ssh-agent`, same
95   `known_hosts` — and a bare `ssh` still resolves to the in-box client, which
96   sits ahead of `C:\Tools\rsync` on the `PATH`. It links against the
97   `libcrypto.dll` the **OpenSSH Client** capability puts in `System32` (Windows'
98   own LibreSSL, which uses AES-NI) and ships no copy of its own, so the elevated
99   half installs that capability first and falls back to `rsync.exe` alone,
100   warning, on an image that will not offer it.
101 - The `rsync` download follows the `releases/latest/download/` redirect rather
102   than the GitHub API: unauthenticated API calls are rate-limited to 60/hour per
103   IP, which a provisioning run behind a shared NAT can genuinely exhaust. To hold
104   a box on a known build, pin the tag in `$RsyncUrl`
105   (`.../releases/download/<tag>/<asset>`) instead.
106 - Visual Studio is installed in three labelled passes (base workload, Clang/LLVM,
107   XP toolset) so a failure identifies which component group is responsible.
108 - The scripts were extracted from a native Windows project, so the component
109   selection is tuned for that: Spectre-mitigated runtimes, the v141/XP toolset,
110   and driver-kit headers. Trim the component lists in the `.ps1` if you don't
111   need them — each group is a plain array near the top.