Harden config perms and key derivation
CI / check-and-test (pull_request) Successful in 11s

Write generated configs 0600, treat new keys as raw AES-256, keep
PBKDF2 for unprefixed material, and cache derivation at startup.
This commit is contained in:
s1d3sw1ped_bot
2026-09-01 04:22:57 +00:00
parent 45778ac528
commit bc486eb49d
8 changed files with 293 additions and 52 deletions
+9 -5
View File
@@ -70,7 +70,7 @@ Both services share the same encrypted tunnel connection!
## Features
- **Secure Encryption**: All traffic is encrypted using AES-GCM encryption with PBKDF2 key derivation
- **Secure Encryption**: All traffic is encrypted using AES-GCM. New keys are raw 256-bit AES keys; passphrase-style configs still use PBKDF2
- **Port Forwarding**: Forward multiple ports with different protocols (TCP and UDP)
- **Configuration-based**: Easy configuration via YAML files
- **Bidirectional**: Full bidirectional port forwarding
@@ -186,8 +186,8 @@ dns_server:
- `"tcp://80:8080"` (client) - listen on `127.0.0.1:8080`, forward to teleport server's port 80
- `"tcp://22:0.0.0.0:2222"` (client) - listen on all interfaces port 2222
- `"udp://53:5353"` (client) - listen on `127.0.0.1:5353`, forward to teleport server's port 53
- `encryption_key`: Shared secret key for encryption (must be the same on both sides)
- `keep_alive`: Enable TCP keep-alive
- `encryption_key`: Shared secret (must be the same on both sides). New keys from `--generate-key` / `--generate-config` are `raw:` plus 64 hex characters (32-byte AES-256 key, no PBKDF2). Unprefixed values — passphrases and hex strings from older `--generate-key` — still go through PBKDF2 so existing configs keep working. To migrate an old hex key to raw AES, re-generate with `--generate-key` and update both sides together; do not strip `raw:` from a new key or add `raw:` to an old hex string.
- `keep_alive`: Enable TCP keep-alive on tunnel and forwarded TCP connections (helps long-lived forwards through NAT)
- `read_timeout`: Read timeout duration
- `write_timeout`: Write timeout duration
- `max_connections`: Maximum concurrent connections (default: 1000 for server, 100 for client)
@@ -265,7 +265,9 @@ dns_server:
./teleport -k
```
This generates a cryptographically secure 256-bit encryption key that you can use in your configuration files.
This prints a `raw:` prefixed 256-bit key. Paste the entire value into `encryption_key` on both server and client. It is used as an AES-256 key directly (no PBKDF2). Existing configs that store a passphrase or an unprefixed hex string still use PBKDF2.
`--generate-config` writes the file mode `0600` because the file embeds a live encryption key.
### Logging Options
@@ -503,6 +505,8 @@ rate_limit:
window_size: 1s # Time window for rate limiting
```
The token bucket is process-global (not per source IP). One noisy peer can consume the budget for everyone; that is enough for a single-user homelab.
### Advanced Logging
@@ -523,7 +527,7 @@ Teleport includes sophisticated logging with:
## Notes
- The encryption key must be identical on both server and client
- Use `./teleport --generate-key` to create a secure random encryption key
- Use `./teleport --generate-key` to create a raw 256-bit AES key (`raw:` + 64 hex). Unprefixed keys in existing configs still use PBKDF2
- The server listens on the specified `listen_address` for incoming tunnel connections (examples bind loopback; `0.0.0.0` must be explicit)
- The client connects to the remote server and forwards local connections from `bind_address` (default `127.0.0.1`)
- All port forwarding is bidirectional