当我输入时ssh remote-host command
,将为我sshd
运行。bash -c command
如何知道用选项sshd
来调用?bash
-c
答案1
哦,该死,这是在 OpenSSH 源代码中硬编码的。
来自OpenSSH 5.9p1源代码的session.c:
/*
* 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);
所以我猜这是一个 POSIX 标准吧?