Tuesday, September 17, 2013

OpenSSH failed to add the hosts to the list of known hosts

Error message:  OpenSSH failed to add the hosts to the list of known hosts

Workstation: Windows 7 x64 Authenticated with domain server
OpenSSH: OpenSSH for Windows v3.8.1p1-1 x64

This issue has been going on for a while in my machine, what is boring is that every time I try to log on to any of my Linux servers the same message appears, asking for confirmation and then showing the error, which prevents me from performing batch tasks and scripts from my workstation against the Linux servers. 

The way to solve this basically has to do with an environment variable that has to be declared, OpenSSH doesn't know the value of $HOME, which is equivalent to the %USERPROFILE% windows variable. So it has to be declred.

Set a Windows User environment variable named HOME that points to the %USERPROFILE%:
  1. Open the Control Panel > System and Security > System
  2. Click on the Advanced System Settings
  3. Click the Environment Variables
  4. In the User variables box click on the "New" Button
  5. Declare a variable named HOME and set its value to %USERPROFILE%
  6. Accept and click OK
Open a new DOS windows and retry, this time instead of the error you should see a warning letting you know the host has just been added:

C:\Users\HMadrid\.ssh>ssh oracle@myHost

The authenticity of host 'myHost (192.168.XX.XX)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'myHost,192.168.xx.xx' (RSA) to the list of known hosts.
oracle@MyHost's password:
Last login: Mon Sep 16 17:33:58 2013 from 192.168.xx.xx
[oracle@stwrac1 ~]$ exit

Connection to myHost closed.

No comments: