I am forwarding a port of a remote server to my local mac as follows:

ssh -L 15672:localhost:15672 [email protected]

When I do this in a shell, I am also logged into example.com. Yet I would like the command to return and not occupy my shell.

Is there an option to do this?

1 Answer 1


You should add -N to avoid getting a shell on the remote, and -f to move the process to the background without losing it if you close the shell.

  • great. That was quick. I will accept when stackexchange let's me.
    – user152468
    Commented Apr 30, 2015 at 15:53
  • 3
    The command is ssh -L 3000:localhost:3000 -Nf remote-host
    – vijayst
    Commented Mar 29, 2022 at 17:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .