Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

1 Answer 1

up vote 5 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);
perror(shell);
exit(1);

So I guess this is a POSIX standard huh?

share|improve this answer
1  
Seems to be yes: pubs.opengroup.org/onlinepubs/009695399/utilities/sh.html –  arjarj Dec 24 '11 at 20:31

Your Answer

 
discard

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.