Newer Older
116 lines | 3.564kb
Bogdan Timofte authored 2 weeks ago
1
# SSH Infrastructure
2

            
3
Source-controlled SSH routing and wrapper configuration for the Next-Gen jump
4
infrastructure.
5

            
6
## Runtime vs project
7

            
8
- Project source: `~/Documents/Workspaces/Bogdan/ssh-infrastructure`
9
- OpenSSH runtime: `~/.ssh`
10

            
11
Keep secrets and machine-local state out of this repository:
12

            
13
- private keys: `~/.ssh/keys/`
14
- `authorized_keys`
15
- `known_hosts`
16
- socket or agent state
17

            
18
The runtime `~/.ssh/config` is a generated single-file OpenSSH config. The
19
project is the place to edit wrappers, documentation, inventory, and generator
20
code.
21

            
22
Deploy the local runtime copy with:
23

            
24
```bash
25
tools/deploy-local.sh
26
```
27

            
28
The deploy script generates `generated/client.conf`, installs it as
29
`~/.ssh/config`, and installs the wrapper commands into `~/.local/bin`.
30
It does not touch keys, `authorized_keys`, or `known_hosts`.
31

            
32
## Version control
33

            
34
This directory is the git repository for source files only. Generated configs,
35
local state, keys, known hosts, and handoff notes stay out of version control.
36

            
37
Track source changes with:
38

            
39
```bash
40
git status
41
git add inventory schema scripts tools .doc README.md .gitignore
42
git commit
43
```
44

            
45
## Current client layout
46

            
47
```text
48
~/.ssh/config
49
~/.local/bin/ssh
50
~/.local/bin/scp
51
~/.local/bin/sftp
52
```
53

            
54
The wrapper sources stay versioned in `scripts/` inside the project; deploy
55
installs executable copies into `~/.local/bin` and removes the obsolete
56
`~/.ssh/scripts` runtime layout from older checkouts.
57

            
58
## Source of Truth
59

            
60
The structured source of truth starts in:
61

            
62
```text
63
inventory/hosts.yaml
64
schema/hosts.schema.json
65
tools/generate-configs.py
66
```
67

            
68
The `generated/*.conf` files are deploy artifacts. They are ignored by git and
69
can be recreated at any time with `tools/deploy-local.sh`.
70

            
71
## Sync from upstream
72

            
73
Pull the upstream inventory, apply this machine's local `is-jumper` key override,
74
regenerate, and deploy if the inventory changed:
75

            
76
```bash
77
tools/sync-hosts-from-upstream.sh
78
```
79

            
80
Defaults:
81

            
82
```text
83
UPSTREAM_SSH_TARGET=nextgen@192.168.2.103
84
UPSTREAM_HOSTS_PATH=/home/nextgen/projects/ssh-infrastructure/inventory/hosts.yaml
85
LOCAL_IS_JUMPER_IDENTITY_FILE=~/.ssh/keys/is-jumper_ed25519
86
DEPLOY_AFTER_SYNC=1
87
```
88

            
89
Useful overrides:
90

            
91
```bash
92
UPSTREAM_HOSTS_FILE=/tmp/hosts.yaml tools/sync-hosts-from-upstream.sh
93
DEPLOY_AFTER_SYNC=0 tools/sync-hosts-from-upstream.sh
94
FORCE_DEPLOY=1 tools/sync-hosts-from-upstream.sh
95
```
96

            
97
Known defaults captured there:
98

            
99
- jump hosts default to user `bogdan.timofte`;
100
- jump hosts default to port `24`, with explicit overrides such as `25904`;
101
- final hosts default to user `bogdan` because most distributions do not like
102
  dotted local usernames;
103
- when imported configs disagree between `bogdan` and `root`, `bogdan` wins;
104
- final hosts default to port `22`, with explicit overrides where needed.
105
- Cisco/TACACS router entries use `auth: password_interactive`; generated SSH
106
  config marks them so the wrapper does not force `BatchMode=yes`.
107
- Imported IFS devices use the canonical hostname already known on the jump
108
  servers as client-side `HostName`, while IPs remain available as aliases for
109
  autocomplete.
110
- J1/J2 configs inherit the company-managed global compatibility block and
111
  selected `Match Host` user/port defaults from the jump servers instead of
112
  duplicating them in generated output.
113
- J1/J2 configs only emit host entries when there is an effective override to
114
  keep on the jump side; hosts that only use inherited defaults are omitted.
115
- J1/J2 generated configs are stripped down to functional SSH stanzas only,
116
  without generated comments or group annotations.