Saturday, December 8, 2012

SCP - RSA Host Key Validation Error

In my previous post (SSH - RSA Host Key Validation Error), I mentioned that SSH will prompt RSA host key validation error if you are connecting to a remote machine that it RSA host key had changed. This will happen if you are connecting to Virtual Machines that share the same IP address.

Actually, not only SSH, SCP will perform the same check and prompt for the same error is RSA host key is mismatch

To work around this issue, you can use the follow command

scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "source file" "destination file"

It uses the exact technic mentioned in my previous post.

SSH - Remote Host Identification Has Changed

When you see the error below, don't panic. It can be a numerous of reasons to encounter this.

Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
Please contact your system administrator.
Add correct host key in /Users/alice/.ssh/known_hosts to get rid of this message.
Offending key in /Users/alice/.ssh/known_hosts:4
RSA host key for has changed and you have requested strict checking.
Host key verification failed.
lost connection

Some reasons

  1. Accessing VM machine with common IP address
  2. IP topology has changed and caused an update to RSA fingerprint

However, if your network/machine has not been changed for N years, you better perform a security scan with your remote machine. It may be tampered with.

For genuine cases, you can remove this warning by removing the existing host key with the following step (I will be using Alice as example)

1. Navigate to your Users folder that contains .ssh

cd /Users/alice/.ssh

2. VI into known_hosts

vi known_hosts

3. Search for the IP address that cause the issues. You can use VI search command


4. If search successful, the cursor will jump to the IP address. Then, delete the entry by dd command


5. Save the modified file


Everything is done. You can ssh to your machine again to verify the warning is gone.

LDAP - Deleting an LDAP entry

To delete an ldif entry, one way is to put an changetype attribute and a value 'delete' in the ldif file For example dn: cn=so...