expand user home directory before using.

Fixes #18670
remove old commented out code
Merge pull request #18777 from UtahDave/2014.7local

2014.7local
Restore salt-cloud ssh_gateway support
Merge pull request #18779 from sjansen/patch-2

Restore salt-cloud ssh_gateway support
Don't change a file again if it's already been done.

When using `append_if_not_found=True` or `prepend_if_not_found=True`
the file will grow infinitely as replace() didn't check until now
whether the change has already been made.

This fixes this behavior (#18612).