1

I followed this guide to create a static IP for my Raspberry Pi running Raspbian Jessie. The static IP is running but my router still lists the old IP address for the Raspberry Pi. I also am no longer able to ssh into my Pi; when I try to ssh using the hostname, the ssh connection times out. On the other hand, when I try to ssh to the static IP, I receive the following 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
<finger print>.
Please contact your system administrator.
Add correct host key in <path to known_hosts file> to get rid of this message.
Offending RSA key in <path to known_hosts file>:21
RSA host key for <raspberry pi static ip> has changed and you have 
requested strict checking.

How do I fix this?

Steve Robillard
  • 34,158
  • 17
  • 102
  • 108
Jay Karimi
  • 111
  • 2
  • The guide you followed apart from being almost illegible is also incorrect (incomplete CIDR addresses) See [How do I set up networking/WiFi/Static IP](http://raspberrypi.stackexchange.com/a/37921/8697) – Milliways Mar 25 '16 at 05:52

2 Answers2

1

NEVER delete a known_hosts file, because it will wipe out all the seen keys! And a MitM attack against you will be much easier. Open it with text editor and replace/delete *a single string starting with a hostname. After a hostname there's a key, so either update the key or delete just one string and connect to a new key+address pair

Alexey Vesnin
  • 926
  • 9
  • 16
-1

You get the warning because you changed the IP address. This is security issue as it could mean you are the subject of a man in the middle attack. To fix the problem you can edit the old entry from the known_hosts file. The file is located in the /home/pi/.ssh directory. You can open it in the editor of your choice and delete its contents.

As for your router seeing the old address that will eventual be removed automatically.

Steve Robillard
  • 34,158
  • 17
  • 102
  • 108
  • is the fact that I can not ssh into the pi using the hostname also a result of the router seeing the old address i.e. will it resolve when the router sees the new static ip address? And how long does that typically take? – Jay Karimi Mar 25 '16 at 05:51
  • If your router only associates the old name with the old address, you won;t be able to use the name without making a change to your hosts file. A search of google for hosts file and your OS will show you how to add an entry for your Pi. As for how long it will take to notice the change I can't say it depends on your router and its configuration. – Steve Robillard Mar 25 '16 at 05:54
  • why would I need to change the hosts file on my laptop; the hostname "raspberrypi" has been configured through the pi's host file using the [following tutorial](http://www.howtogeek.com/167195/how-to-change-your-raspberry-pi-or-other-linux-devices-hostname/) – Jay Karimi Mar 25 '16 at 05:59
  • can you resolve the host name from your laptop? I am betting no, hence why you can reach the box by ip and not by name – Steve Robillard Mar 25 '16 at 06:00
  • prior to the static ip attempts, yes. If I remove the static ip config in `/etc/dhcpcd.conf`, then my laptop is able to resolve the hostname over ssh again – Jay Karimi Mar 25 '16 at 06:01
  • but you can't with the static IP which is waht you started out to do. Make the hosts file change and see if it works – Steve Robillard Mar 25 '16 at 06:02
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/37502/discussion-between-jay-karimi-and-steve-robillard). – Jay Karimi Mar 25 '16 at 06:03