$ ssh -f -N -v -t -L 5433:target_host:5432 user@jump_server
- target_host is the host/database_server/RDS that you want to access that only can be accessed from jump _server or bastion if you’re using AWS
- jump_server is the host that accessible from you and the only host that can access target_host
- 5432 is local port (postgresql default)
- 5433 is the forwarded host/database_server/RDS port that you can access through localhost
What’s next?
Afterwards, you should be able to get postgresql open with forwarded port through localhost (5433).Test the forwarded port using telnet:
$ telnet localhost 5433
or using netcat:
$ nc -vz localhost 5433