Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I type ssh remote-host command, sshd will run bash -c command for me.

How does sshd know to invoke bash with -c option?

share|improve this question
up vote 7 down vote accepted

Oh dammit, this is hardcoded in OpenSSH's source code.

From session.c of OpenSSH 5.9p1 source code:

 * Execute the command using the user's shell.  This uses the -c
 * option to execute the command.
argv[0] = (char *) shell0;
argv[1] = "-c";
argv[2] = (char *) command;
argv[3] = NULL;
execve(shell, argv, env);

So I guess this is a POSIX standard huh?

share|improve this answer
Seems to be yes: – arjarj Dec 24 '11 at 20:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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