Skip to content

Commit d9ff112

Browse files
committed
cf ssh sequence diagram
1 parent b27da11 commit d9ff112

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

ssh_flow.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
```mermaid
2+
sequenceDiagram
3+
participant User
4+
participant cf as cf CLI
5+
participant LB as L4 Load Balancer (ssh.cf.{domain}:2222)
6+
participant HA as HAProxy (optional, not in default CF setup)
7+
participant UAA
8+
participant Proxy as ssh_proxy
9+
participant CC as Cloud Controller
10+
participant BBS
11+
participant TLS as TLS Proxy Sidecar (container)
12+
participant sshd as diego-sshd (container)
13+
14+
User->>cf: cf ssh myapp
15+
16+
Note over cf,CC: Get ssh route and host key fingerprint
17+
cf->>CC: GET /
18+
CC-->>cf: app_ssh.href: ssh.cf.{domain}:2222, app_ssh.meta.host_key_fingerprint
19+
20+
Note over cf,UAA: Get one-time authorization code
21+
cf->>UAA: GET /oauth/authorize?response_type=code&client_id=ssh-proxy (Bearer: existing CF access token)
22+
UAA-->>cf: 302 redirect with ?code=XyZ9...
23+
24+
Note over cf,LB: SSH entrypoint via load balancer
25+
cf->>LB: TCP connect ssh.cf.{domain}:2222
26+
LB->>HA: L4 pass-through to HAProxy backend port 2222
27+
HA->>Proxy: Forward TCP stream to ssh_proxy job
28+
29+
Note over cf,Proxy: SSH connection (encrypted after KEX)
30+
cf->>Proxy: SSH KEX (verify proxy host key against app_ssh_host_key_fingerprint from CF / info endpoint)
31+
cf->>Proxy: SSH userauth password=XyZ9..., user="cf:app-guid/instance-index"
32+
33+
Note over Proxy,UAA: Exchange code for token
34+
Proxy->>UAA: POST /oauth/token grant_type=authorization_code code=XyZ9... (Basic: ssh-proxy:secret)
35+
UAA-->>Proxy: access_token (JWT)
36+
37+
Note over Proxy,CC: Check SSH access permission
38+
Proxy->>CC: GET /internal/apps/app-guid/ssh_access/index (Bearer: access_token)
39+
CC-->>Proxy: 200 OK (SSH allowed)
40+
41+
Note over Proxy,BBS: Look up container address and keys
42+
Proxy->>BBS: ActualLRP + DesiredLRP for process_guid and process_version
43+
BBS-->>Proxy: container host:port, TLS address, host_fingerprint, private_key
44+
45+
Note over Proxy,TLS: Dial backend endpoint for app instance
46+
Proxy->>TLS: TLS dial (mTLS), verify ServerCertDomainSAN == instance_guid
47+
TLS->>sshd: plain TCP to backend sshd endpoint
48+
49+
Note over Proxy,sshd: SSH KEX with container daemon
50+
Proxy->>sshd: SSH KEX
51+
sshd-->>Proxy: host public key
52+
Proxy->>Proxy: verify host public key against host_fingerprint from DesiredLRP diego-ssh route
53+
Note right of Proxy: WARNING: if host key does not match host_fingerprint, reject connection and fail SSH
54+
55+
Note over Proxy,sshd: Authenticate to daemon
56+
Proxy->>sshd: SSH userauth publickey, private_key from DesiredLRP diego-ssh route (same keypair as -authorizedKey on sshd)
57+
sshd->>sshd: verify public key against -authorizedKey arg
58+
sshd-->>Proxy: auth success
59+
60+
Note over Proxy,sshd: Forward channel and data
61+
Proxy->>sshd: open session channel
62+
sshd-->>Proxy: channel open confirm
63+
User->>cf: interact with ssh session (PTY, exec, shell)
64+
cf->>LB: TCP data forwarding
65+
LB->>HA: TCP data forwarding
66+
HA->>Proxy: TCP data forwarding
67+
Proxy->>sshd: TCP data forwarding
68+
```

0 commit comments

Comments
 (0)