Summary: | someone eats the 1st line of "bash -c 'echo aaa; echo bbb; echo ccc'" | ||
---|---|---|---|
Product: | Branch 4.0 | Reporter: | Ivan Zakharyaschev <imz> |
Component: | openssh-server | Assignee: | Dmitry V. Levin <ldv> |
Status: | CLOSED NOTABUG | QA Contact: | Q.A. 4.0 <qa-4.0> |
Severity: | normal | ||
Priority: | P2 | CC: | evg |
Version: | 4.0 | ||
Hardware: | all | ||
OS: | Linux |
Description
Ivan Zakharyaschev
2008-09-21 18:14:15 MSD
This is also true for: openssh-server-3.6.1p2-alt1 openssh-clients-3.6.1p2-alt1 bash-3.1.17-alt1 The ssh protocol passes command line as a string. That is, all ssh args gets merged into one space separated string and passed to the server side, where sshd executes shell -c string. Compare: ssh 0 bash -c 'echo aaa; echo bbb; echo ccc' and ssh 0 "bash -c 'echo aaa; echo bbb; echo ccc'" (In reply to comment #2) Thanks for the answer! > Compare: > ssh 0 bash -c 'echo aaa; echo bbb; echo ccc' > and > ssh 0 "bash -c 'echo aaa; echo bbb; echo ccc'" > And: $ bash -c "bash -c echo aaa; echo bbb; echo ccc" bbb ccc $ bash -c 'echo $1 $2' 0 1 2 1 2 $ Now it's clear. (In reply to comment #3) > $ bash -c "bash -c echo aaa; echo bbb; echo ccc" This command does the same as bash -c "bash -c echo; echo bbb; echo ccc" (In reply to comment #2) > The ssh protocol passes command line as a string. > That is, all ssh args gets merged into one space separated string and > passed to the server side, where sshd executes shell -c string. Actually, the usage format "ssh hostname command [arg]..." is not documented, so it it was not correct for me to expect a certain behavior from this undocumented feature. The manpage shows just a single command argument. Now I see that this format is confusing, and the problem would be obvious if I used a single command argument as suggested by the manpage (ssh imz@etik 'bash -c echo a; echo b; echo c'). |