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?

link|improve this question

29% accept rate
feedback

1 Answer

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?

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

Your Answer

 
or
required, but never shown

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