|

How to connect a database via ssh tunnel

When you need to connect the remote database that is behind the firewall or the jumpbox. Use this command to connect the target database via ssh tunnel.

ssh -N -L <localport>:<database-host>:<database-port> <jumpbox-username>:<jumpbox-password>@<jumpbox-host>

Example

ssh -N -L 2345:postesql-database:5432 jjunx:<jumpbox-password>@19.168.6.123

Then, keep that terminal opens.

Try to connect the database from local

psql -h localhost -p 2345 -d postgres -U postgres

Basic commands that you should know

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *