Fix the default shell

Go with whatever is set by SSH, and fall back to "linux" if the terminal is not available.

This fixes #1975