I use WinSSHd on several Windows servers. To access them from my Mac (and presumably, just about any Unix-based terminal), I need to set the TERM environment variable to cygwin, e.g.:

TERM=cygwin ssh someserver.com

I can also use the .ssh/config to set certain defaults for that server, such as a different user and non-default port:

host someserver.com
    User SomeDifferentDude
    Port 22222

However, I apparently can't set environment variables that way. I haven't found anything in man ssh_config, anyway. Is there a way to set the default terminal emulation (and/or any environment variable) per host?


You would typically set the environment variable on the server side.

If WinSSHd is sufficiently like openssh (the usual unix implementation of ssh), you can define an environment file (~/.ssh/environment on unix) and put TERM=cygwin there.

You can also set the environment variable in your shell initialization file. Since you mention cygwin, this is presumably ~/.bash_profile where ~ is your cygwin home directory. You should set it conditionally, in case you also use cygwin on other terminal types; for example, to set it only if you are logging in over ssh (again, assuming WinSSHd is sufficiently like openssh):

if [ -n "$SSH_CLIENT" ]; then
  export TERM=cygwin
|improve this answer|||||
  • Thanks. I couldn't find a way to set environment variables in its server settings, but ended up finding a much better solution. – Sören Kuklau Aug 15 '10 at 9:43

It turns out there's a much better solution — WinSSHd supports Unix's terminfo format, so all I had to do is copy the proper terminfo file (in the case of OS X: xterm-color) into its directory, and the TERM=cygwin setting become unnecessary.

|improve this answer|||||

You can use SendEnv TERM to set the TERM on the server to be the same as the TERM on your local machine.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.