SSH shell quoting - fixes 318, 331

Fixes #318, #331.

This doesn't explicitly test that quoting is done, which I can add if requested, but the SSH tests now fail if quoting is disabled because they use things like `(` and spaces in their commands.