Setup -N parameter in SSH Config File

16

3

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?>

veilig

Posted 2012-12-13T15:38:13.737

Reputation: 801

Answered here https://unix.stackexchange.com/a/417373/69080. Try RemoteCommand cat

– Joshua Huber – 2018-05-24T13:53:41.123

Sounds like a case of the XY problem. What exactly do you want to do?

– terdon – 2012-12-13T16:02:26.643

@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 – 2012-12-13T16:37:08.100

Why don't you just run ssh -N, why do you need to set this as a config parameter? – terdon – 2012-12-13T16:43:42.900

Answers

2

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.

johnshen64

Posted 2012-12-13T15:38:13.737

Reputation: 4 399

Ubuntu 12.04, I looked at the ssh_config man page but unless I overlooked it I didn't see it possible. – veilig – 2012-12-13T16:34:05.430

2

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

kinds

NauT

Posted 2012-12-13T15:38:13.737

Reputation: 325

1

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

Joshua Huber

Posted 2012-12-13T15:38:13.737

Reputation: 171