feat: Implement server CLI interface (bssh-server binary) (#131)#150
Merged
feat: Implement server CLI interface (bssh-server binary) (#131)#150
Conversation
Implement the bssh-server binary with comprehensive CLI interface for managing the SSH server. Features: - Main commands: run, gen-config, hash-password, check-config, gen-host-key, version - Global CLI arguments: -c/--config, -b/--bind-address, -p/--port, -k/--host-key, -v/--verbose, -D/--foreground, --pid-file - Configuration file loading with CLI overrides - Signal handling for graceful shutdown (SIGTERM, SIGINT) - Password hashing with bcrypt (cost factor 12) - SSH host key generation (Ed25519/RSA) - Configuration validation and checking - Proper error handling and exit codes Technical details: - Uses clap for CLI parsing with derive API - Integrates with existing ServerFileConfig from issue #130 - Supports both file-based and CLI-based configuration - Added dependencies: bcrypt 0.16, rand 0.8, ssh-key 0.6 - All clippy checks pass with -D warnings Resolves #131
- Fix host key file race condition by using atomic file creation with mode 0o600 - Add exclusive PID file lock check to prevent multiple server instances - Add password complexity warning for passwords shorter than 8 characters - Set restrictive permissions (0600) on generated config files
- Add 19 new unit tests covering CLI parsing, subcommands, and options - Test gen-config with file output and permissions validation - Test gen-host-key for Ed25519/RSA with permission checks - Test write_pid_file including stale PID handling - Test all CLI parsing scenarios and global options - Update ARCHITECTURE.md with Server CLI Binary documentation - Update docs/architecture/README.md with server CLI references - Update docs/architecture/server-configuration.md with CLI commands section - Fix formatting issues in bssh_server.rs (cargo fmt)
Member
Author
PR Finalization ReportProject Structure Discovered
ChecklistTests
Documentation
Code Quality
Changes Made
Verification Results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the
bssh-serverbinary with a comprehensive CLI interface for starting and managing the SSH server, resolving issue #131.Implementation Details
Commands Implemented
Global CLI Arguments
-c, --config- Configuration file path-b, --bind-address- Bind address override-p, --port- Port override-k, --host-key- Host key file(s) override-v, --verbose- Verbosity level (repeatable: -v, -vv, -vvv)-D, --foreground- Run in foreground--pid-file- PID file pathFeatures
✓ Configuration loading from YAML files with CLI overrides
✓ Signal handling for graceful shutdown (SIGTERM, SIGINT)
✓ Password hashing with bcrypt (cost factor 12)
✓ SSH host key generation (Ed25519 recommended, RSA supported)
✓ Configuration validation and checking
✓ Proper error handling and exit codes
✓ Integration with existing ServerFileConfig from #130
Technical Changes
src/bin/bssh_server.rswith full CLI implementationCargo.tomlto add binary target and dependencies:bssh-server.yamlto.gitignoreTesting
-D warningsUsage Examples
Related Issues
Checklist