Have remote_expanduser honor sudo and su users.

Fixes #9663