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