I would like to use the -N flag in my ssh config file, but I'm not sure how to do this?

Is it possible?

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

Host foo
    HostName foo.bar.com
    User baz
    <how can I add -N flag here?>
  • Sounds like a case of the XY problem. What exactly do you want to do? – terdon Dec 13 '12 at 16:02
  • @terdon I am trying to pass the -N flag to ssh for a gitolite server my work has that appears to be slow during push/pull. I was told this will stop ssh from executing a shell on startup and loading the environment and stuff which is contributing to the lag I'm experiencing. – veilig Dec 13 '12 at 16:37
  • Why don't you just run ssh -N, why do you need to set this as a config parameter? – terdon Dec 13 '12 at 16:43
  • Answered here unix.stackexchange.com/a/417373/69080. Try RemoteCommand cat – Joshua Huber May 24 '18 at 13:53

Which OS? Do a man ssh_config and see if your ssh has such an option. On linux it this option is not available as a config parameter. As far as I know, I think the same is true with other openssh or similar clients in other platforms.

| improve this answer | |
  • Ubuntu 12.04, I looked at the ssh_config man page but unless I overlooked it I didn't see it possible. – veilig Dec 13 '12 at 16:34

actually -N is not a parameter but just a flag like -l or else

if you don't want to have command ssh -N -l username HOSTNAME you can create alias ssh = "ssh -N" (on the host from where you want to ssh to your gitolite server.

another idea that came to my mind , the slowness of ssh can be because of DNS also, on connection server is trying to resolve hostname of machine which is trying to connect and if there are a wrong entry in DNS or no info available it will become slow on connection


| improve this answer | |

Answered here https://unix.stackexchange.com/a/417373/69080. Starting in OpenSSH 7.6, there is an option called RemoteCommand. Try adding to your config file:

RemoteCommand cat

When using this, I also like to also include:

LogLevel DEBUG
| improve this answer | |

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.