All posts

Pgcli SSH Access Proxy: Simplifying Database Access for Developers

Connecting to a remote database via SSH can be cumbersome, especially when you need intuitive tools like Pgcli, the popular command-line interface for PostgreSQL. If you’re looking for an efficient way to run Pgcli through an SSH Access proxy, this guide will help you streamline the process with ease. Why Use Pgcli With an SSH Access Proxy? Pgcli provides an advanced command-line experience with features like auto-completion and syntax highlighting for PostgreSQL databases. However, it’s comm

Free White Paper

Database Access Proxy + SSH Access Management: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

Connecting to a remote database via SSH can be cumbersome, especially when you need intuitive tools like Pgcli, the popular command-line interface for PostgreSQL. If you’re looking for an efficient way to run Pgcli through an SSH Access proxy, this guide will help you streamline the process with ease.


Why Use Pgcli With an SSH Access Proxy?

Pgcli provides an advanced command-line experience with features like auto-completion and syntax highlighting for PostgreSQL databases. However, it’s common for these databases to reside on servers locked behind SSH for security purposes. This additional layer of protection often complicates direct access.

When you’re using Pgcli, you may hit bottlenecks such as:

  • Managing SSH keys or credentials for secure access.
  • Setting up tunnels manually each time.
  • Debugging inconsistent connections or port-forwarding errors.

Instead of repeatedly creating SSH tunnels or relying on manual commands, using an SSH Access proxy makes remote access seamless.


How an SSH Access Proxy Works

An SSH Access proxy plays the middleman for securely connecting local tools like Pgcli to servers hosting your PostgreSQL database. It eliminates the need for repeated tunnel setups and handles connections directly.

Here’s what the proxy does:

  1. Authenticates securely using your SSH credentials.
  2. Maps a local port to a remote PostgreSQL port.
  3. Keeps the connection open while you query the database using Pgcli.

With this workflow, you don’t have to manage cumbersome tunnels—just route your Pgcli commands through the configured proxy and focus on querying data.


Configuring Pgcli with an SSH Access Proxy

Setting up Pgcli to work through an SSH proxy is straightforward when broken down into steps.

Step 1: Verify SSH Access

Ensure you can SSH into the remote server hosting your PostgreSQL database without issues. Test this using:

Continue reading? Get the full guide.

Database Access Proxy + SSH Access Management: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
ssh user@remote-host

If you’re prompted for a password or key passphrase, follow through and confirm access.

Step 2: Identify Database Connection Details

You’ll need the following information:

  • PostgreSQL username and database name.
  • Remote database host or IP address.
  • Port number (the PostgreSQL default is 5432).

Step 3: Start an SSH Proxy

Manually create a local port-forward using the ssh command:

ssh -L 5433:localhost:5432 user@remote-host

Here’s what this command does:

  • -L 5433:localhost:5432 binds your local port 5433 to the remote port 5432 (PostgreSQL default).
  • user@remote-host authenticates over SSH to the remote host.

Leave this terminal session running.

Step 4: Connect Pgcli to the Locally Forwarded Port

Once the tunnel is active, connect Pgcli using:

pgcli -h localhost -p 5433 -U postgres your-database

This command routes Pgcli queries from your local machine to the database server via the tunnel you set up.


Automating Access With Tools

Manually setting up and tearing down SSH tunnels works, but it adds overhead. By adopting tools that automate SSH Access proxies, you can simplify this process.

Solutions like Hoop handle the tunneling securely in the background, allowing you to focus on querying with Pgcli. Hoop’s seamless setup ensures you won’t need to repeat manual steps every time you want access, and it removes the guesswork by automating credential management and proxy configuration.


See It in Action

If you’re tired of troubleshooting SSH tunnels or juggling credentials, it’s time to simplify your setup. With tools like Hoop.dev, you can connect Pgcli to your remote PostgreSQL database in minutes—no manual configuration required. Try it now and see how much faster and cleaner your workflow can be.

Streamline your database access today with Hoop.dev and experience instant, secure connections.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts