1 command ssh session

Damien Miller djm at mindrot.org
Thu Nov 13 00:01:27 EST 2008


On Mon, 10 Nov 2008, Michael Loftis wrote:

> No, it simply exec's it from the PATH/env given to the SSHD.  There's an 
> option to force it to init a shell or something like that if you want (or 
> for some reason need) the overhead.  I forget what it is but I'm sure 
> someone here can enlighten.

This is quite incorrect. The code that starts the session looks like
this (from session.c):

 1311|  /*
 1312|   * Get the shell from the password data.  An empty shell field is
 1313|   * legal, and means /bin/sh.
 1314|   */
 1315|  shell = (pw->pw_shell[0] == '\0') ? _PATH_BSHELL : pw->pw_shell;
...
 1411|  /* Get the last component of the shell name. */
 1412|  if ((shell0 = strrchr(shell, '/')) != NULL)
 1413|          shell0++;
 1414|  else
 1415|          shell0 = shell;
...
 1444|  /*
 1445|   * Execute the command using the user's shell.  This uses the -c
 1446|   * option to execute the command.
 1447|   */
 1448|  argv[0] = (char *) shell0;
 1449|  argv[1] = "-c";
 1450|  argv[2] = (char *) command;
 1451|  argv[3] = NULL;
 1452|  execve(shell, argv, env);
 1453|  perror(shell);
 1454|  exit(1);

I.e. it will use the user's shell from /etc/passwd or /bin/sh if none is
specified.

-d


More information about the openssh-unix-dev mailing list