Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

What is the meaning of "Do not execute a remote command"?

In the man page of ssh, it says:
-N    Do not execute a remote command.  This is useful for just forwarding ports.

I don't understand what it means by "Do not execute a remote command."

Can someone explain it to me?
by

1 Answer

Amit8z4mc
Usually, ssh will give you a remote shell by executing what is set up as your remote users login shell (e.g. /bin/bash). -N will prevent running anything, which is useful when you just want to use ssh to establish a connection and you don't need a remote shell.

e.g. forwarding ports or creating tunnels:
ssh -N -L 8080:127.0.0.1:80 user@server


And this is not only useful for forwarding ports.

E.g.: I use it in combination with -f and ControlMaster and ControlPath options (e.g. set up in .ssh/config), it can be used to create reusable connections.
ssh -fN user@server # creates a connection in the background that can be reused.

Login / Signup to Answer the Question.