sesc360
sesc360

Reputation: 3255

Remote host Identification has changed

I try to copy a file to my remote server with scp.

sudo scp atlassian-jira-6.4-x64.bin username@ip-adress:/

When I execute, I get the error:

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
(fingerprint)
Please contact your system administrator.
Add correct host key in /var/root/.ssh/known_hosts to get rid of this message.
Offending RSA key in /var/root/.ssh/known_hosts:1
RSA host key for IPADRESS has changed and you have requested strict checking.
Host key verification failed.

So I removed the known_hosts file from ~/.ssh and tried the command again. But still there is this message coming up. Where do I need to modify my files then besides the .ssh folder?

Upvotes: 0

Views: 9668

Answers (3)

Pierre de LESPINAY
Pierre de LESPINAY

Reputation: 46178

In case you actually need to connect to different hosts with the same IP, for example through different LAN or VPN, you'll want to declare both as known.

  • Connect to the LAN/VPN A
ssh-keyscan -H 192.168.X.Y >> ~/.ssh/known_hosts
  • Connect to the LAN/VPN B
ssh-keyscan -H 192.168.X.Y >> ~/.ssh/known_hosts

This retrieves the public keys of both servers and adds them on your known hosts.

With that you won't have the MITM security warning (since there is no issue) while keeping the actual MITM security protection.

Upvotes: 0

Ashot Avetisyan
Ashot Avetisyan

Reputation: 33

In case if the problem is repetitive, you can try to use this method.

Add the following lines to the beginning of the SSH configuration file.

Host *
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null

or for a specific host

Host localhost
        HostName localhost
        UserKnownHostsFile=/dev/null
        StrictHostKeyChecking=no

Upvotes: 1

Altmish-E-Azam
Altmish-E-Azam

Reputation: 1583

Edit the known_host file under following directory using vim editor on terminal.

 vi     /var/root/.ssh/known_hosts OR  /root/.ssh/known_hosts

delete all lines using dd command and save the known_hosts file using :wq! and restart your sshd service.

service sshd restart

Upvotes: 2

Related Questions