psequel icon indicating copy to clipboard operation
psequel copied to clipboard

Add SSH Tunneling Support for Database Connections

Open ppvan opened this issue 10 months ago • 0 comments

Background

Currently, our database client lacks SSH tunneling capabilities, which is essential for securely accessing remote databases that aren't directly accessible over the internet. Many production databases are only accessible from within private networks, requiring SSH tunneling as a secure method to establish connections.

Problem

Users cannot connect to databases that:

  • Are behind firewalls allowing only SSH access
  • Require connecting through bastion/jump hosts
  • Are in private networks with restricted direct access

Proposed Solution

Implement SSH tunneling support using GIO and libssh2-vala bindings. This will allow users to:

  1. Create secure SSH tunnels to remote hosts
  2. Forward local ports to remote database ports
  3. Connect to databases through these tunnels

Technical Implementation

We can utilize these Vala libraries:

  • libssh2: Provides SSH protocol implementation
  • Gio.SocketClient: For handling network connections
  • Gio.TcpConnection: For managing TCP connections

Reference Projects

  1. Sequeler (Database Client written in Vala):

    • Has implemented SSH tunneling in Vala
    • https://github.com/ellie-commons/sequeler
  2. DBeaver (Java-based):

    • Has robust SSH implementation
    • Good reference for UX patterns

User Experience

Users should be able to configure:

  • SSH host details (hostname, port)
  • Authentication method (password/key-based)
  • Local and remote port forwarding settings
  • Save SSH configurations alongside database connections

Security Considerations

  • Support for key-based authentication
  • Secure storage of SSH credentials (May be ask for .ssh access inside flatpak is bad)
  • Proper tunnel shutdown on application close

ppvan avatar Feb 19 '25 17:02 ppvan