9

I use

ssh -D 1080 myhost.org

...to open up an SSH tunnel from my work machine to my home machine, so as to bypass the idiotic content filter on the corporate firewall. However this also creates an interactive SSH session that lives the whole time I'm using the tunnel. Is there any way to tell SSH just to create the tunnel and not bother with the interactive session?

3 Answers 3

13

Seems like you want the -N flag.

ssh -D 1080 -N myhost.org
4
  • 5
    It's recommended to use -fnN in conjunction.
    – kolypto
    Nov 26, 2009 at 1:46
  • 1
    I'd even recommend to use autossh to manage reconnects in such cases.
    – jollyroger
    Jun 19, 2012 at 12:18
  • How do you stop the ssh connection in this case? When you're done with that remote endpoint and want to connect to something else on that port?
    – Mnebuerquo
    Jan 4, 2018 at 20:28
  • @Mnebuerquo For ad-hoc tunnels I simply kill the process when I'm done with the tunnel. For more commonly used tunnels I have them defined as systemd --user units.
    – andol
    Jan 6, 2018 at 17:33
4

from ssh manpage:

 -N      Do not execute a remote command. This is
         useful for just forwarding ports (protocol version 2 only).
3

I've typically found this to be better because it not only stops listening to commands, but also goes into the background.

SSH -D 1080 -N -f yourhost.org

You must log in to answer this question.

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