Skip to content

feat: adds ssh support for git operations #987

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dcoric
Copy link

@dcoric dcoric commented Apr 28, 2025

This PR implements SSH support for Git operations, resolving #27. The implementation allows users to perform Git operations over SSH protocol, providing an alternative to HTTPS for repository access.

Changes

  1. Added SSH server implementation using ssh2 library
  2. Implemented two authentication methods:
    • Public key authentication
    • Password authentication
  3. Added SSH configuration options in config.schema.json
  4. Created comprehensive SSH documentation in docs/SSH.md
  5. Added SSH server tests in test/ssh/sshServer.test.js

Configuration

SSH support can be configured in the main configuration file:

{
  "ssh": {
    "enabled": true,
    "port": 2222,
    "hostKey": {
      "privateKeyPath": "./.ssh/host_key",
      "publicKeyPath": "./.ssh/host_key.pub"
    }
  }
}

Usage

Users can connect using standard Git SSH commands. The command format depends on the configured port:

  • If port is set to 22 (default SSH port):

    git clone git@your-proxy:username/repo.git
  • If using a custom port (e.g., 2222):

    git clone ssh://git@your-proxy:2222/username/repo.git

Testing

Added comprehensive tests for SSH functionality:

  • Server initialization
  • Authentication methods
  • Connection handling
  • Git protocol support

Documentation

Added detailed documentation in docs/SSH.md covering:

  • Configuration options
  • Authentication methods
  • Security features
  • Usage instructions
  • Troubleshooting guide

Future Improvements

  1. Move SSH configuration options (keep alive, timeouts, and other params) to config file
  2. Enhance actions for SSH functionality
  3. Increase test coverage
  4. Improved error reporting
  5. Additional security features

This implementation provides a secure and reliable way to perform Git operations over SSH, giving users more flexibility in how they interact with their repositories.

Below is a summary of the most important changes:

SSH Feature Implementation:

  • Added a new ssh configuration section in config.schema.json and proxy.config.json to enable SSH support, configure the port, and specify host key paths. ([[1]](https://github.com/finos/git-proxy/pull/987/files#diff-be1695b1e63a508d59982601f9e1fb7f58247deecb1e427adb77bcad758ae5e5R82-R111), [[2]](https://github.com/finos/git-proxy/pull/987/files#diff-c465aafa0fe603e2d28b017938f55e5ce3253aac7aa303efeabfc06a4ad52d5fR105-R112))
  • Created docs/SSH.md to provide comprehensive documentation for configuring, using, and troubleshooting the SSH feature. ([docs/SSH.mdR1-R165](https://github.com/finos/git-proxy/pull/987/files#diff-1d0301881738da7c699d7634669c5156c345a5094d6c012cfa7254cbdf15cbd2R1-R165))
  • Integrated SSH key management into the CLI, including commands to add and remove SSH keys (addSSHKey function and ssh-key command). ([[1]](https://github.com/finos/git-proxy/pull/987/files#diff-ee51eb1c2264303569f2a8fa9f5bb2de1b6b51eed24eed943d079f341f4139b0R310-R363), [[2]](https://github.com/finos/git-proxy/pull/987/files#diff-ee51eb1c2264303569f2a8fa9f5bb2de1b6b51eed24eed943d079f341f4139b0R494-R524), [[3]](https://github.com/finos/git-proxy/pull/987/files#diff-c3c551630c7afb35431840ab36bd8cc771deb1fa385b73804eaf8da4b8db7e0cR1-R122))

Database Enhancements:

  • Updated the user schema to include SSH public keys and added functions for managing SSH keys (addPublicKey, removePublicKey, findUserBySSHKey). ([[1]](https://github.com/finos/git-proxy/pull/987/files#diff-d90c8ba033b20fb64a27fb6f16a94afa5ebc2f25bb7af6ec42cd260dcbf46710R43-R46), [[2]](https://github.com/finos/git-proxy/pull/987/files#diff-d90c8ba033b20fb64a27fb6f16a94afa5ebc2f25bb7af6ec42cd260dcbf46710R98-R155), [[3]](https://github.com/finos/git-proxy/pull/987/files#diff-c7d2c320d1f7fc0aad36b8bf616a7289ca4dcf00e6e057ba8a1d354fb25b74c0R84-R86))

Configuration and Code Updates:

  • Introduced new methods in src/config/index.ts to retrieve SSH-related settings (getSSHConfig, getSSHProxyUrl). ([[1]](https://github.com/finos/git-proxy/pull/987/files#diff-198a1431d7c5e26ea78bc6e54b34b54e6f8ab342dd48ea11013877e8466a87c5R33), [[2]](https://github.com/finos/git-proxy/pull/987/files#diff-198a1431d7c5e26ea78bc6e54b34b54e6f8ab342dd48ea11013877e8466a87c5R48-R58))
  • Updated package.json to include the ssh2 library and its TypeScript types for SSH server implementation. ([[1]](https://github.com/finos/git-proxy/pull/987/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R75), [[2]](https://github.com/finos/git-proxy/pull/987/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519R90))

Documentation Enhancements:

  • Updated README.md to include a link to the new SSH documentation. ([README.mdR88-R95](https://github.com/finos/git-proxy/pull/987/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R88-R95))

These changes collectively enable the SSH feature, providing an alternative to HTTPS for secure Git operations while enhancing user control and security.

Copy link

netlify bot commented Apr 28, 2025

Deploy Preview for endearing-brigadeiros-63f9d0 ready!

Name Link
🔨 Latest commit 83a7496
🔍 Latest deploy log https://app.netlify.com/sites/endearing-brigadeiros-63f9d0/deploys/680f748167a5250008b99805
😎 Deploy Preview https://deploy-preview-987--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 site configuration.

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.

1 participant