You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DOCS/configuration/CONFIG-JSON.md
+170-1Lines changed: 170 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,7 +185,19 @@ These settings are now managed client-side.
185
185
"envAllowlist": ["ONLY_THIS", "AND_THAT"],
186
186
"maxExecOutputBytes": 10485760,
187
187
"outputRateLimitBytesPerSec": 0,
188
-
"socketHighWaterMark": 16384
188
+
"socketHighWaterMark": 16384,
189
+
"hostKeyVerification": {
190
+
"enabled": false,
191
+
"mode": "hybrid",
192
+
"unknownKeyAction": "prompt",
193
+
"serverStore": {
194
+
"enabled": true,
195
+
"dbPath": "/data/hostkeys.db"
196
+
},
197
+
"clientStore": {
198
+
"enabled": true
199
+
}
200
+
}
189
201
},
190
202
"options": {
191
203
"challengeButton": true,
@@ -419,3 +431,160 @@ These options can also be configured via environment variables:
419
431
-`WEBSSH2_SSH_SFTP_TIMEOUT`
420
432
421
433
See [ENVIRONMENT-VARIABLES.md](./ENVIRONMENT-VARIABLES.md) for details on environment variable format and examples.
434
+
435
+
### Host Key Verification
436
+
437
+
SSH host key verification provides TOFU (Trust On First Use) protection against man-in-the-middle attacks. It supports three modes of operation: server-only (SQLite store), client-only (browser localStorage), and hybrid (server-first with client fallback).
438
+
439
+
#### Configuration Options
440
+
441
+
-`ssh.hostKeyVerification.enabled` (boolean, default: `false`): Enable or disable host key verification. When disabled (the default), all host keys are accepted without verification.
442
+
443
+
-`ssh.hostKeyVerification.mode` (`'server'` | `'client'` | `'hybrid'`, default: `'hybrid'`): Operational mode. `server` uses only the SQLite store, `client` uses only the browser localStorage store, `hybrid` checks the server store first and falls back to the client store for unknown keys. The mode sets sensible defaults for which stores are enabled, but explicit store flags override mode defaults.
444
+
445
+
-`ssh.hostKeyVerification.unknownKeyAction` (`'prompt'` | `'alert'` | `'reject'`, default: `'prompt'`): Action when an unknown key is encountered (no match in any enabled store). `prompt` asks the user to accept or reject, `alert` allows the connection with a warning, `reject` blocks the connection.
446
+
447
+
-`ssh.hostKeyVerification.serverStore.enabled` (boolean): Whether the server-side SQLite store is active. Defaults are derived from `mode` but can be overridden explicitly.
448
+
449
+
-`ssh.hostKeyVerification.serverStore.dbPath` (string, default: `'/data/hostkeys.db'`): Path to the SQLite database file. The application opens it read-only. Use `npm run hostkeys` to manage keys.
450
+
451
+
-`ssh.hostKeyVerification.clientStore.enabled` (boolean): Whether the client-side browser localStorage store is active. Defaults are derived from `mode` but can be overridden explicitly.
452
+
453
+
#### Default Host Key Verification Configuration
454
+
455
+
```json
456
+
{
457
+
"ssh": {
458
+
"hostKeyVerification": {
459
+
"enabled": false,
460
+
"mode": "hybrid",
461
+
"unknownKeyAction": "prompt",
462
+
"serverStore": {
463
+
"enabled": true,
464
+
"dbPath": "/data/hostkeys.db"
465
+
},
466
+
"clientStore": {
467
+
"enabled": true
468
+
}
469
+
}
470
+
}
471
+
}
472
+
```
473
+
474
+
> **Note:** Host key verification is disabled by default. Set `enabled` to `true` to activate it.
475
+
476
+
#### Use Cases
477
+
478
+
**Enable with hybrid mode (recommended):**
479
+
```json
480
+
{
481
+
"ssh": {
482
+
"hostKeyVerification": {
483
+
"enabled": true,
484
+
"mode": "hybrid"
485
+
}
486
+
}
487
+
}
488
+
```
489
+
Server store is checked first. If the key is unknown on the server, the client's browser store is consulted. Unknown keys prompt the user.
490
+
491
+
**Server-only mode (centrally managed keys):**
492
+
```json
493
+
{
494
+
"ssh": {
495
+
"hostKeyVerification": {
496
+
"enabled": true,
497
+
"mode": "server",
498
+
"unknownKeyAction": "reject"
499
+
}
500
+
}
501
+
}
502
+
```
503
+
Only the server SQLite store is used. Unknown keys are rejected — administrators must pre-seed keys via `npm run hostkeys`.
504
+
505
+
**Client-only mode (no server database):**
506
+
```json
507
+
{
508
+
"ssh": {
509
+
"hostKeyVerification": {
510
+
"enabled": true,
511
+
"mode": "client"
512
+
}
513
+
}
514
+
}
515
+
```
516
+
Only the client browser store is used. Users manage their own trusted keys via the settings UI.
517
+
518
+
**Alert-only (log but don't block):**
519
+
```json
520
+
{
521
+
"ssh": {
522
+
"hostKeyVerification": {
523
+
"enabled": true,
524
+
"mode": "server",
525
+
"unknownKeyAction": "alert"
526
+
}
527
+
}
528
+
}
529
+
```
530
+
Unknown keys show a warning indicator but connections proceed. Useful for monitoring before enforcing.
Mode is `server` but `clientStore.enabled` is explicitly set to `true`, making it behave like hybrid. Explicit flags always take precedence over mode defaults.
546
+
547
+
#### Seeding the Server Store
548
+
549
+
Use the built-in CLI tool to manage the SQLite database:
550
+
551
+
```bash
552
+
# Probe a host and add its key
553
+
npm run hostkeys -- --host server1.example.com
554
+
555
+
# Probe a host on a non-standard port
556
+
npm run hostkeys -- --host server1.example.com:2222
557
+
558
+
# Import from OpenSSH known_hosts file
559
+
npm run hostkeys -- --known-hosts ~/.ssh/known_hosts
560
+
561
+
# List all stored keys
562
+
npm run hostkeys -- --list
563
+
564
+
# Remove keys for a host
565
+
npm run hostkeys -- --remove server1.example.com
566
+
567
+
# Use a custom database path
568
+
npm run hostkeys -- --db /custom/path/hostkeys.db --host server1.example.com
569
+
```
570
+
571
+
#### Environment Variables
572
+
573
+
These options can also be configured via environment variables:
574
+
-`WEBSSH2_SSH_HOSTKEY_ENABLED`
575
+
-`WEBSSH2_SSH_HOSTKEY_MODE`
576
+
-`WEBSSH2_SSH_HOSTKEY_UNKNOWN_ACTION`
577
+
-`WEBSSH2_SSH_HOSTKEY_DB_PATH`
578
+
-`WEBSSH2_SSH_HOSTKEY_SERVER_ENABLED`
579
+
-`WEBSSH2_SSH_HOSTKEY_CLIENT_ENABLED`
580
+
581
+
See [ENVIRONMENT-VARIABLES.md](./ENVIRONMENT-VARIABLES.md) for details.
0 commit comments