Skip to content

Conversation

@fabiovincenzi
Copy link
Contributor

This PR adds an SSH-key management UI. Based on #987

To ease review, a separate PR has been opened against the SSH integration branch to highlight only the UI-related changes: G-Research#52

  • Frontend

    • Every key is displayed only by its SHA-256 fingerprint,
    • New SSH tab in the clone popup
  • Backend – Two endpoints make it work:

    • GET /:username/ssh-keys → returns all fingerprints for the user.
    • DELETE /:username/ssh-keys/fingerprint → accepts { fingerprint } in the body and removes the matching key.
Screenshot 2025-05-28 at 13 30 09 Screenshot 2025-05-28 at 13 29 56 Screenshot 2025-05-28 at 13 29 50

Note: Restored from deleted fork

This PR recreates the **original PR #1033 **, which was automatically closed due to accidental fork deletion.

** For discussions and reviews:** See the original PR #1033

All commits are identical to the original with preserved git history.

@netlify
Copy link

netlify bot commented Aug 4, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 failed. Why did it fail? →

Name Link
🔨 Latest commit 9d37ac9
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/68fb3461c3ca1600080a425c

- Implement complete SSH server with public key and password authentication
- Add SSH key management to user database (both File and MongoDB)
- Create SSH CLI tools for key management
- Add SSH configuration schema and TypeScript types
- Integrate SSH server with main proxy lifecycle
- Add REST endpoints for SSH key CRUD operations
- Include comprehensive test suite and documentation
- Support Git operations over SSH with full proxy chain integration
- Convert SSH server (src/proxy/ssh/server.js -> server.ts)
- Convert SSH CLI tool (src/cli/ssh-key.js -> ssh-key.ts)
- Add proper TypeScript types and interfaces
- Install @types/ssh2 for SSH2 library types
- Fix TypeScript compilation errors with type assertions
- Update imports to use TypeScript files
- Remove @ts-expect-error comment as no longer needed
- Add email and gitAccount fields to SSHUser and AuthenticatedUser interfaces
- Improve client connection handling by logging client IP and user details
- Refactor handleClient method to accept client connection info
- Enhance error handling and logging for better debugging
- Update tests to reflect changes in client handling and authentication
- Update keepalive settings to recommended intervals for better connection stability
- Implement cleanup of keepalive timers on client disconnects
- Modify error handling to allow client recovery instead of closing connections
- Improve logging for debugging client key usage and connection errors
- Update tests to reflect changes in keepalive behavior and error handling
dcoric and others added 16 commits September 17, 2025 13:55
- Introduce SSH key management to securely store and reuse user SSH keys during the approval process
- Add SSHKeyManager and SSHAgent classes for key encryption, storage, and expiration management
- Implement captureSSHKey processor to capture and store SSH key information during push actions
- Enhance Action and request handling to support SSH-specific user data
- Update push action chain to include SSH key capture
- Extend PushData model to include encrypted SSH key and expiration details
- Provide configuration options for SSH key encryption and management
 - Introduce .nvmrc file to specify Node.js version (v20)
- Add SSH interface definitions for configuration of SSH proxy server and host keys
- Update config generation to include SSH settings
- Modify SSH server command handling to improve error reporting and session
  management
- Enhance tests for SSH key capture and server functionality, ensuring robust
  error handling and edge case coverage
- Add .claude/ to .gitignore to prevent tracking of Claude-related files
…handling in SSH server

- Update SSH configuration merging to guarantee 'enabled' is always a boolean value.
- Enhance error handling in SSH server to provide clearer error messages when chain execution fails.
Fixes SSH push operations by capturing pack data before executing
the security chain. Previously SSH pushes failed because pack data
was streamed directly without capture, causing parsePush processor
to fail with null body.

Changes:
- Split push/pull operation handling with proper timing
- Capture pack data from SSH streams for push operations
- Execute security chain after pack data is available for pushes
- Execute security chain before streaming for pulls
- Add comprehensive error handling and timeout protection
- Forward captured pack data to remote after security approval
- Add size limits (500MB) and corruption detection

Security: All existing security features now work for SSH pushes
including gitleaks scanning, diff analysis, and approval workflows.

Test coverage: 91.74% line coverage with comprehensive unit and
integration tests covering pack capture, error scenarios, and
end-to-end workflows.
Prevents the accidental committing of SSH keys generated during tests.
- Updated the test to use forwardPackDataToRemote for handling git-receive-pack commands.
- Added async handling for stream events to ensure proper execution flow.
- Skipped the pack data corruption detection test to prevent false positives.
- Improved assertions for error messages related to access denial and remote forwarding failures.

These changes improve the robustness and reliability of the SSHServer tests.
Added support for maximum pack size limits in proxy configuration,
allowing for better control over git operations.

Introduced new SSH clone configuration options,
including service token credentials for cloning repositories.

Updated configuration types to include limits and SSH clone settings.

Enhanced the handling of SSH keys during push operations,
ensuring proper encryption and management of user keys.

Improved error handling and logging for SSH operations, providing clearer feedback during failures.

These changes improve the flexibility and security of git operations within the proxy server.
@fabiovincenzi
Copy link
Contributor Author

Superseded by #1276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants