Skip to content

Commit 03cdf52

Browse files
authored
Split SSH config fragments and move OpenTofu to Homebrew (#96)
1 parent f001979 commit 03cdf52

16 files changed

+395
-89
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ _audit/
2424
# Local reference repos
2525
_reference/
2626

27+
skills/.SKILLS_MANAGED_BY_JSM
28+
2729
# Local compiled tools
2830
bin/browser-tools
2931
scripts/node_modules/

README.md

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ The `setup-ssh-from-1password.sh` script manages SSH configuration with security
181181
#### Default (Safe) Mode
182182

183183
```bash
184-
# Download SSH config + public keys only (private keys stay in 1Password)
184+
# Download base SSH config + per-profile fragment + public keys only
185185
./setup-ssh-from-1password.sh
186186

187187
# Check what's available without downloading
@@ -190,7 +190,8 @@ The `setup-ssh-from-1password.sh` script manages SSH configuration with security
190190

191191
In safe mode:
192192

193-
- Downloads SSH config from 1Password (stored as Secure Note)
193+
- Downloads base SSH config from 1Password (stored as Secure Note)
194+
- Downloads a per-profile SSH config fragment from 1Password
194195
- Downloads **public keys only** for reference
195196
- Private keys remain in 1Password
196197
- Uses 1Password SSH Agent for authentication
@@ -252,19 +253,40 @@ This approach:
252253

253254
1. Open 1Password and create new item → SSH Key
254255
2. Name it exactly as expected by the script:
255-
- `github_personal_authentication`
256-
- `github_personal_signing`
257-
- `aws_work_2024_client_1`
258-
- `github_work_2025_client_1`
256+
- `personal_github_authentication`
257+
- `personal_github_signing`
258+
- `work_2024_client_1_aws`
259+
- `work_2025_client_1_github`
260+
- `work_2025_client_2_github`
261+
- `work_2025_client_2_ado`
259262
3. Paste your private key
260-
4. Save to "Private" vault (or adjust `VAULT` in script)
263+
4. Save to the vault expected by the script for that key
261264

262265
#### SSH Config
263266

264267
1. Create new item → Secure Note
265-
2. Name it: `SSH Config`
266-
3. Paste your complete SSH configuration
267-
4. Save to "Private" vault
268+
2. Name it: `~/.ssh/config`
269+
3. Add your base SSH configuration, for example:
270+
271+
```sshconfig
272+
Host *
273+
IdentityAgent "~/.1password/agent.sock"
274+
275+
Include ~/.ssh/config.d/*.conf
276+
```
277+
278+
4. Save it in the vault selected by `SSH_CONFIG_VAULT` or `VAULT`
279+
280+
#### SSH Config Fragments
281+
282+
1. Create new item → Secure Note
283+
2. Name it as one of:
284+
- `~/.ssh/config.d/personal.conf`
285+
- `~/.ssh/config.d/work-2024-client-1.conf`
286+
- `~/.ssh/config.d/work-2025-client-1.conf`
287+
- `~/.ssh/config.d/work-2025-client-2.conf`
288+
3. Add only the host stanzas for that profile
289+
4. Save it in the same vault as that profile's SSH keys
268290

269291
#### Git Config
270292

@@ -275,6 +297,11 @@ This approach:
275297
```ini
276298
[url "github-work:OrgName/"]
277299
insteadOf = [email protected]:OrgName/
300+
insteadOf = https://github.com/OrgName/
301+
302+
[url "git@ado-work-2025-client-2:v3/ORG/PROJECT/"]
303+
insteadOf = [email protected]:v3/ORG/PROJECT/
304+
278305
[user]
279306
280307
```

_configs/focus/infrastructure.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ tools:
1717
documentation_url: "https://terraform.io"
1818
category: infrastructure
1919

20-
tofu:
21-
manager: arkade
22-
type: get
20+
opentofu:
21+
manager: brew
22+
type: package
2323
check_command: command -v tofu
2424
description: "Open-source Terraform fork"
2525
documentation_url: "https://opentofu.org/"

_test/1password.bats

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,36 @@ if [[ "$1" == "item" ]] && [[ "$2" == "get" ]]; then
7373
cat <<'CONFIG'
7474
Host *
7575
IdentityAgent "~/.1password/agent.sock"
76-
77-
Host github-work
78-
HostName github.com
79-
User git
80-
IdentityFile ~/.ssh/work_key.pub
76+
Include ~/.ssh/config.d/*.conf
8177
CONFIG
8278
else
8379
echo "~/.ssh/config found"
8480
fi
8581
exit 0
8682
;;
83+
"~/.ssh/config.d/personal.conf")
84+
if [[ "$@" == *"--fields"* ]] && [[ "$@" == *"notes"* ]]; then
85+
cat <<'CONFIG'
86+
Host github.com
87+
HostName github.com
88+
User git
89+
IdentityFile ~/.ssh/personal_github_authentication.pub
90+
IdentitiesOnly yes
91+
CONFIG
92+
else
93+
echo "~/.ssh/config.d/personal.conf found"
94+
fi
95+
exit 0
96+
;;
8797
"work .gitconfig_include")
8898
if [[ "$@" == *"--fields"* ]] && [[ "$@" == *"notes"* ]]; then
8999
cat <<'GITCONFIG'
90100
[url "github-work:OrgName/"]
91101
insteadOf = [email protected]:OrgName/
102+
insteadOf = https://github.com/OrgName/
103+
104+
[url "git@ado-work-2025-client-2:v3/ORG/PROJECT/"]
105+
insteadOf = [email protected]:v3/ORG/PROJECT/
92106
93107
[user]
94108
@@ -98,7 +112,7 @@ GITCONFIG
98112
fi
99113
exit 0
100114
;;
101-
"personal_github_authentication"|"personal_github_signing"|"work_aws_2024_client_1"|"work_github_2025_client_1")
115+
"personal_github_authentication"|"personal_github_signing"|"work_2024_client_1_aws"|"work_2025_client_1_github")
102116
echo "$item_name found"
103117
exit 0
104118
;;
@@ -132,7 +146,8 @@ EOF
132146
[ "$status" -eq 0 ]
133147
[[ "$output" == *"SSH Config Dry Run"* ]]
134148
[[ "$output" == *"Found in 1Password:"* ]]
135-
[[ "$output" == *"~/.ssh/config (Secure Note)"* ]]
149+
[[ "$output" == *"~/.ssh/config (Secure Note, vault: Private)"* ]]
150+
[[ "$output" == *"~/.ssh/config.d/personal.conf"* ]]
136151
[[ "$output" == *"personal_github_authentication"* ]]
137152
[[ "$output" == *"No files were modified"* ]]
138153
}
@@ -152,9 +167,19 @@ if [[ "$1" == "account" ]] && [[ "$2" == "list" ]]; then
152167
fi
153168
154169
if [[ "$1" == "item" ]] && [[ "$2" == "get" ]]; then
155-
if [[ "$@" == *"--fields notes"* ]]; then
170+
if [[ "$3" == "~/.ssh/config" ]] && [[ "$@" == *"--fields notes"* ]]; then
156171
echo "Host *"
157172
echo " IdentityAgent ~/.1password/agent.sock"
173+
echo "Include ~/.ssh/config.d/*.conf"
174+
exit 0
175+
fi
176+
177+
if [[ "$3" == "~/.ssh/config.d/personal.conf" ]] && [[ "$@" == *"--fields notes"* ]]; then
178+
echo "Host github.com"
179+
echo " HostName github.com"
180+
echo " User git"
181+
echo " IdentityFile ~/.ssh/personal_github_authentication.pub"
182+
echo " IdentitiesOnly yes"
158183
exit 0
159184
fi
160185
@@ -179,6 +204,9 @@ EOF
179204
grep -q "public key" "$TEST_DIR/op-calls.log"
180205
run grep -q "private key" "$TEST_DIR/op-calls.log"
181206
[ "$status" -ne 0 ]
207+
[ -f "$HOME/.ssh/config.d/personal.conf" ]
208+
run grep -q "Host github.com" "$HOME/.ssh/config.d/personal.conf"
209+
[ "$status" -eq 0 ]
182210
}
183211

184212
@test "SSH setup: unsafe mode requires confirmation" {

_test/shell-configs.bats

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ EOF
181181
[ "$status" -eq 0 ]
182182
}
183183

184+
@test "zshrc: prepends docker completions directory to fpath when present" {
185+
mkdir -p "$HOME/.docker/completions"
186+
touch "$HOME/.docker/completions/_docker"
187+
188+
result=$(/bin/zsh -c "
189+
export HOME='$HOME'
190+
export DOTFILES_DIR='$DOTFILES_DIR'
191+
source $DOTFILES_DIR/zsh/.zshrc 2>/dev/null
192+
print -r -- \$fpath[1]
193+
")
194+
195+
[ "$result" = "$HOME/.docker/completions" ]
196+
}
197+
184198
@test "zshrc: direnv only initialized when direnv exists" {
185199
# Test without direnv - should not error
186200
run zsh -c "
@@ -276,11 +290,18 @@ EOF
276290
skip "No suitable 'time' command with -p flag available"
277291
fi
278292

293+
local zdotdir="$HOME/zdotdir"
294+
mkdir -p "$zdotdir"
295+
ln -sf "$DOTFILES_DIR/zsh/.zshrc" "$zdotdir/.zshrc"
296+
if [ -f "$DOTFILES_DIR/zsh/.zshenv" ]; then
297+
ln -sf "$DOTFILES_DIR/zsh/.zshenv" "$zdotdir/.zshenv"
298+
fi
299+
279300
local -a zsh_cmd=(
280301
env
281302
HOME="$HOME"
282303
DOTFILES_DIR="$DOTFILES_DIR"
283-
ZDOTDIR="$DOTFILES_DIR/zsh"
304+
ZDOTDIR="$zdotdir"
284305
TERM="xterm-256color"
285306
zsh -i -c exit
286307
)

claude/.claude/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"model": "opus[1m]",
23
"statusLine": {
34
"type": "command",
45
"command": "bash -c 'input=$(cat); cwd=$(echo \"$input\" | jq -r \".workspace.current_dir // .cwd\"); display_dir=\"${cwd/#$HOME/\\~}\"; printf \"\\033[38;5;85m\\033[1m%s\\033[0m\" \"$display_dir\"; if git -C \"$cwd\" rev-parse --git-dir >/dev/null 2>&1; then branch=$(git -C \"$cwd\" --no-optional-locks branch --show-current 2>/dev/null || echo \"detached\"); printf \" \\033[1mgit\\033[0m \\033[0;32m\\033[1m%s\\033[0m\" \"$branch\"; status=$(git -C \"$cwd\" --no-optional-locks status --porcelain 2>/dev/null); if [ -n \"$status\" ]; then modified=$(echo \"$status\" | grep -c \"^ M\" || true); untracked=$(echo \"$status\" | grep -c \"^??\" || true); staged=$(echo \"$status\" | grep -c \"^M\" || true); status_info=\"\"; [ \"$staged\" -gt 0 ] && status_info+=\"$(printf \"\\033[0;32m✓%s\\033[0m \" \"$staged\")\"; [ \"$modified\" -gt 0 ] && status_info+=\"$(printf \"\\033[0;34m!%s\\033[0m \" \"$modified\")\"; [ \"$untracked\" -gt 0 ] && status_info+=\"$(printf \"\\033[0;36m?%s\\033[0m \" \"$untracked\")\"; [ -n \"$status_info\" ] && printf \" %s\" \"$status_info\"; fi; fi; if [ -f \"$cwd/package.json\" ] && command -v node >/dev/null 2>&1; then node_version=$(node --version 2>/dev/null | sed \"s/v//\"); printf \" \\033[0;32m\\033[1m󰎙 %s\\033[0m\" \"$node_version\"; fi; if ls \"$cwd\"/*.tf >/dev/null 2>&1; then printf \" \\033[1mterraform\\033[0m\"; fi; current_time=$(date \"+%H:%M\"); printf \" [%s]\" \"$current_time\"; echo'"
@@ -8,6 +9,5 @@
89
"frontend-design@claude-code-plugins": true,
910
"pr-review-toolkit@claude-code-plugins": true
1011
},
11-
"alwaysThinkingEnabled": true,
12-
"model": "opus"
12+
"alwaysThinkingEnabled": true
1313
}

setup-gitconfig-from-1password.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ if [ ${#failed_configs[@]} -gt 0 ]; then
283283
echo ' [url "github-work-alias:OrgName/"]'
284284
echo ' insteadOf = [email protected]:OrgName/'
285285
echo ' insteadOf = https://github.com/OrgName/'
286+
echo ' [url "git@ado-work-2025-client-2:v3/ORG/PROJECT/"]'
287+
echo ' insteadOf = [email protected]:v3/ORG/PROJECT/'
286288
echo ' [user]'
287289
echo ' email = [email protected]'
288290
fi

0 commit comments

Comments
 (0)