Skip to content

Instantly share code, notes, and snippets.

@scottjbarr
Last active September 20, 2017 23:09
Show Gist options
  • Save scottjbarr/1b86a0f2eb7d1d1bbefd25052707f3a8 to your computer and use it in GitHub Desktop.
Save scottjbarr/1b86a0f2eb7d1d1bbefd25052707f3a8 to your computer and use it in GitHub Desktop.
Setup a tunnel to an RDS instance and install PostgreSQL tools from source

SSH Tunnel To RDS

Setup a tunnel

This sets up a tunnel from localhost:6432, to rds-instance:5432, via the host at ec2-instance

ssh -N -L 6432:rds-instance:5432 ec2-instance

Connect To RDS Instance

psql -h localhost -p 6432

Install Postgres

You will postgres tools for a version that matches the version of Postgres on the RDS instance.

Basically, if the RDS instance is Postgres 9.5, you will need postgresql-9.5 client tools to use pg_dump.

cd /tmp
wget https://ftp.postgresql.org/pub/source/v9.5.4/postgresql-9.5.4.tar.bz2
tar -jxf postgresql-9.5.4.tar.bz2
cd postgresql-9.5.4
./configure --prefix=$HOME/usr/local/postgresql/9.5.4
make && make install

# delete the source
rm -rf /tmp/postgresql-9.5.4*

Postgresql 9.5.4 tools will now be available at $HOME/usr/local/postgresql/9.5.4/bin

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment