I'm trying to open an ssh connection to let one server access a remote postgres database. So I followed the instructions in this postgres help page.
When I run the command:
ssh -L 3333:foo.com:5432 [email protected]
It connects me automatically to the remote server the same way it would with a regular ssh. At that point my connection works fine. The problem I'm facing is when I close the terminal, the connection is lost so I looked on how to run that same command in the background but with no luck. This is what I tried but it doesn't actually work:
nohup ssh -L 3333:foo.com:5432 [email protected] &
How can I run the ssh -L tunneling command in the background?
Thanks in advance.
ssh -L 3333:localhost:5432 [email protected]is the usual way, contrary tossh -L 3333:foo.com:5432 [email protected]which generally leads to Connection refused. See a more recent version of the help page you linked to at: postgresql.org/docs/9.3/static/ssh-tunnels.html which has been updated to explain this.