Nothing new under the sun, but this is how I use it, and I’m reporting it here since I’ve found some misleading indications out on the net. Remote machine is with SSH running on non-standard port 12345
ssh -p12345 -L 3333:localhost:5432 root@
After this, you can connect to port 3333 on localhost to access remote postgresql DB server.