Question

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 joe@foo.com

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 joe@foo.com &

How can I run the ssh -L tunneling command in the background?

Thanks in advance.

Was it helpful?

Solution

After trying few options of ssh, I actually found the solution. Here it is:

ssh -f -N -L 3333:foo.com:5432 joe@foo.com
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top