Scrub SSH PTY output to filter out command echo-ing.
Preserve exit code while using pseudo-terminal hack.
Merge pull request #4408 from lsimons/ssh-scrub-pty-output-for-upstream

core: Scrub SSH PTY output to filter out command echo-ing and most other cruft