These work,
ssh remote 'echo hi > hi.txt'
echo hi | ssh remote 'cat > hi.txt'
but this does not work
ssh remote sh -c 'echo hi > hi.txt'
I expected to produce a file on remote named hi.txt containing "hi". Instead I get an empty file named hi.txt.
The following gives the expected behavior if executed from an interactive ssh session.
sh -c 'echo hi > hi.txt'
What do I miscomprehend about ssh and redirection?