Earlier while trying to SSH to a device from a Terminal windows on my Macbook Pro running OSX version 10.8, also known as Mountain Lion, I received an error when attempting to connect to a 64 Bit Windows 7 Professional server. The error in the Mac Terminal window stated that the terminal failed to initialize. After troubleshooting I realized that the Windows 7 Pro server, which is running WinSSHD as an SSH server, didn’t like the default terminal emulation that the Terminal window, which is xterm-color256, in OSX Mountain Lion uses. Below we describe the error message in more detail and how to resolve this issue within the Terminal window itself or by installing iTerm2.
First I am going to show the initial error that caused me to start looking at the default terminal emulation type in OSX Mountain Lion and helped me discover iTerm2 which I personally like better than the default Mac Terminal window. I typically use SecureCRT for SSH but many times if I already have a Terminal window open and I just need to test something quickly then I SSH directly from the OSX Terminal window. I typically don’t recommend paid applications unless they are inexpensive and SecureCRT is not at around $99. Anyhow it is a great SSH application so if you use SSH often you might consider it though iTerm2 which is mentioned in more detail below will also provide a great Mac Terminal window replacement.
Terminal Initialization Failure Connecting To WinSSHD:
- MacBook-Pro:~ alex$ ssh ssh-user@example-domain@192.168.1.10
- ssh-user@example-domain@192.168.1.10's password:
- Permission denied, please try again.
- ssh-user@example-domain@192.168.1.10's password:
- Terminal initialization failure. See server logs for more info.
- Hint: Try requesting a different terminal environment.
- Connection to 192.168.1.10 closed.
- MacBook-Pro:~ alex$
As you can see above I attempt to SSH directly from a Terminal window on my Macbook only to have the remote end (the Windows 7 Pro Running WinSSHD) complain about my terminal emulation type or terminal environment and close the connection. I also first wanted to display the difference in errors if the password was incorrect so the very first attempt in the example above shows what the response would be if the username or password is incorrect as you would simply be denied instead of receiving the terminal initialization error. Below I describe two ways to get around this issue which is done by changing the default terminal emulation from xterm-color256 to vt100 or really to whatever other type you like. I am going to show the easiest method first which does not require you to install any software.
Modify Default Terminal Emulation Type For Mac Terminal Window:
- Launch Terminal Window Preferences: Open a Terminal window on your Mac and make sure it is active. Click Terminal in the top navigation window and select Preferences from the drop down menu as shown in the below example image.
- Open Advanced Terminal Settings: When the Terminal Preferences window initially opens it will likely be open to the Startup tab however the setting we are going to modify is under the Settings tab so click the Settings tab at the top of the window. Next the sub tab that is initially active is likely the Text tab however our setting is located underneath the Advanced tab so click that now to display a Terminal Preferences window similar to the below example image.
- Modify Terminal Emulation: Now click the drop down next to Declare Terminal As to modify the terminal emulation type to vt100 as shown in the below example. It should be noted that other terminal emulation types will also work without issue but I prefer vt100 because I am used to this terminal emulation type as it is one of the default terminal emulations in SecureCRT which I mentioned above.
- Save Settings & Restart Terminal Window: To save your new terminal emulation type simple close the Terminal Preferences window. You also need to close any open Mac Terminal windows and launch a new one for the terminal emulation to change to vt100. Once you have launched a new window you should be able to SSH to WinSSHD without issue as shown in the below example output.
- MacBook-Pro:~ alex$ ssh ssh-user@example-domain@192.168.1.10
- ssh-user@example-domain@192.168.1.10's password:
- Microsoft Windows [Version 6.1.7601]
- Copyright (c) 2009 Microsoft Corporation. All rights reserved.
- C:\\Users\\ssh-user\\>
- C:\\Users\\ssh-user>
- C:\\Users\\ssh-user>exit
- Connection to 192.168.1.10 closed.
- MacBook-Pro:~ alex$
There you have it… you can now successfully SSH from the OSX Terminal window to WinSSHD. The even better news is you also know how to modify the Mac Terminal window terminal emulation type with ease! Now if you are not a huge fan of Terminal on OSX a great replacement application is called iTerm2 which started out as iTerm long ago. Follow along below to install iTerm2 on your Mac.
Replace Terminal On OSX With iTerm2:
First download iTerm2 from the iTerm2 Google Code page located here. Unzip the download, which should be named something like iTerm2-1_0_0_20121224.zip, by double clicking on it. This will create a folder called something like iTerm2-1_0_0_20121224 which you should open to reveal the iTerm.app file. Drag that file into your Applications folder on your Mac and you have now installed iTerm2. Open Applications and double click on iTerm.app to launch iTerm2 as shown in the below example.
iTerm2 On Mac OSX:
You should try it out and see if iTerm is a viable replacement for your Terminal window!