Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres Tunneling SSH -L In background

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.

like image 433
Maher Manoubi Avatar asked Dec 31 '25 01:12

Maher Manoubi


1 Answers

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

ssh -f -N -L 3333:foo.com:5432 [email protected]
like image 196
Maher Manoubi Avatar answered Jan 01 '26 20:01

Maher Manoubi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!