Skip to content

Conversation

@fabiovincenzi
Copy link
Contributor

This PR adds SSH key management UI to git-proxy. Based on #987

Review Note

This PR includes all changes from the base SSH PR it's built upon. To simplify the review process, you can check G-Research#63 which is opened against this PR's branch and shows only the UI integration changes made specifically for SSH functionality.

Features

Frontend

  • SSH key management section in User profile page
    • Add SSH keys via modal dialog with validation
    • Display keys by SHA-256 fingerprint with name and date
    • Delete keys by fingerprint
  • HTTPS/SSH tabs in clone popup for repository URLs

Backend

Three API endpoints handle SSH key management:

  • GET /api/v1/user/:username/ssh-key-fingerprints → Returns fingerprint metadata (name, fingerprint, addedAt) for the user
  • POST /api/v1/user/:username/ssh-keys → Accepts public key and name, calculates fingerprint server-side
  • DELETE /api/v1/user/:username/ssh-keys/:fingerprint → Removes key identified by fingerprint in URL path

Database

  • Implemented SSH key CRUD operations for both File and MongoDB
  • Added PublicKeyRecord type

CLI

  • Updated ssh-key command to use fingerprint-based deletion
Screenshot 2025-11-06 at 15 56 33 Screenshot 2025-11-06 at 15 58 08 Screenshot 2025-11-06 at 15 58 24 Screenshot 2025-11-06 at 15 58 41 Screenshot 2025-11-06 at 15 59 00

dcoric and others added 30 commits September 12, 2025 15:56
- 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
- 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.
@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit df87a30
🔍 Latest deploy log https://app.netlify.com/projects/endearing-brigadeiros-63f9d0/deploys/69148c1aa1360700082c481a
😎 Deploy Preview https://deploy-preview-1276--endearing-brigadeiros-63f9d0.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@fabiovincenzi fabiovincenzi mentioned this pull request Nov 7, 2025
@fabiovincenzi fabiovincenzi linked an issue Nov 7, 2025 that may be closed by this pull request
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.

[Feat] Add UI management for public SSH keys

3 participants