I built a docker image from Ubuntu with OpenSSH server installed. Suppose I request a simple command over ssh
ssh root@172.17.0.2 "sleep 10"
Then, ps aux --forest inside the container gives me this:
SER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 18 0.3 0.0 18508 3500 pts/0 Ss 16:12 0:00 bash
root 37 0.0 0.0 34404 2884 pts/0 R+ 16:12 0:00 \_ ps aux --forest
root 16 0.0 0.0 72300 3280 ? Ss 16:12 0:00 /usr/sbin/sshd
root 34 0.0 0.0 74656 6648 ? Ss 16:12 0:00 \_ sshd: root@notty
root 36 0.0 0.0 4532 744 ? Ss 16:12 0:00 \_ sleep 1000
But when I execute a more complex command like
ssh root@172.1.70.2 "sleep 1000; sleep 1"
It now spawns a bash shell and passes my command to it:
root 18 0.1 0.0 18508 3500 pts/0 Ss 16:12 0:00 bash
root 43 0.0 0.0 34404 2896 pts/0 R+ 16:13 0:00 \_ ps aux --forest
root 16 0.0 0.0 72300 3280 ? Ss 16:12 0:00 /usr/sbin/sshd
root 39 0.0 0.0 74656 6712 ? Ss 16:13 0:00 \_ sshd: root@notty
root 41 0.0 0.0 9920 1312 ? Ss 16:13 0:00 \_ bash -c sleep 1000; sleep 1
root 42 0.0 0.0 4532 776 ? S 16:13 0:00 \_ sleep 1000
So, which part decides whether to invoke a shell or not? Is that controlled by SSHd? If so, is there a way to force SSHd to always invoke shell?
P.S. I know that in Ruby, Kernel.exec is the function that chooses to spawn or not to spawn a shell based on meta-characters like ; and &, so maybe in my case the choice is not made on the application level?