openssh-unix-dev October 2011 archive
Main Archive Page > Month Archives  > openssh-unix-dev archives
openssh-unix-dev: Re: Information on command execution in sshd

Re: Information on command execution in sshd

From: Daniel Kahn Gillmor <dkg_at_nospam>
Date: Sun Oct 02 2011 - 17:39:16 GMT
To: titu senapati <titu_senapati@yahoo.com>

On 10/02/2011 08:22 AM, titu senapati wrote:

> I was going through the code of open ssh server part ( code for sshd ). My query is when user gives any command ( for example unix command "ls")
> in the console ( after ssh login is complete ), which function in sshd will execute this command. I traced that the command is coming to sshd code
> in message type SSH2_MSG_CHANNEL_DATA. There is a check using function packet_check_eom(). But I am not able to trace the place
> where linux command "ls" will be executed. I want to know the function in sshd code which will execute this function.

In the common case, sshd invokes a child process of the user's shell
upon session creation. Then when the user types a command like "ls",
that command gets shuttled across ssh as channel data (as you've seen)
and handed as input to the child process (the shell).

It is the shell which interprets the "ls" as a command and in turn
invokes /bin/ls (or whatever).

So sshd doesn't invoke ls directly at all. Make sense?

hope this helps,

        --dkg

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev