8

I would like to setup one of the SSH connections in my ssh_config file to use the -N ssh flag. I can't find any matching config keyword for this parameter. I'm using the connection for port forwarding only and I would like it to use -N every time I execute ssh host. I'm using mosh for the interactive shell.

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

I'm fairly sure you can't do that and like you I can't find a way of doing it in the manner that you want. If typing ssh -N host doesn't appeal then you could always try creating an alias if mosh supports it.

  • Yeah thanks, my plan was to use the ssh config together with the ssh workflow for Alfred (OS X). That would allow me to type ssh vps01 in Alfred and have it launch a terminal window for forwarding without the shell. Guess I'll have to solve it some other way then :) – Daniel Johansson Sep 11 '13 at 13:34
  • @DanielJohansson: I don't know anything about mosh but in bash you could alias it. – Iain Sep 11 '13 at 13:41
  • This answer is almost 3 years old. Has anything changed in the meantime? – vog Aug 9 '16 at 14:59
1

I don't know about mosh, but for the OpenSSH client you can specify a ProxyCommand in the config file. The relevant entry for hostname foobar.baz.edu (my favorite university) and dynamic forwarding of port 9999 would be:

Host FooBar
   HostName foobar.baz.edu
   ProxyCommand ssh -ND 9999 %h
  • This is not really relevant to the question. -N and ProxyCommand are not the same thing. – kasperd Sep 26 '18 at 23:10
  • 1
    Right, they are not, but this approach lets OP do what they say they want to do: set up one of the SSH connections in their ssh_config file to use the -N ssh flag, so they don't have to use -N every time they execute ssh host. – user1093043 Sep 27 '18 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.