Skip to content

Instantly share code, notes, and snippets.

@paolobrasolin
Created October 15, 2021 15:41
Show Gist options
  • Save paolobrasolin/fe1bf0a8646fd9304223c216367b5ef6 to your computer and use it in GitHub Desktop.
Save paolobrasolin/fe1bf0a8646fd9304223c216367b5ef6 to your computer and use it in GitHub Desktop.
Open an SSH tunnel to a PG socket
#!/usr/bin/env bash
DB=${1:-my-host}
PORT=${2:-10864}
echo "Opened tunnel on port $PORT to $DB through websocket..."
ssh -N -L localhost:$PORT:/var/run/postgresql/.s.PGSQL.5432 $DB
echo "Closed!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment