Fix the default terminal

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