treehouses / treehouses.github.io

A Markdown Wiki for treehouses 🏡
http://treehouses.io
132 stars 107 forks source link

SSH fails when RPI has been re-imaged #313

Closed john-dunbar closed 4 years ago

john-dunbar commented 4 years ago

Problem

After flashing the RPI with a treehouses image for the second time, I went to SSH into it and was presented with an error and denied access to the RPI.

The problem was that when I connected to the RPI over SSH for the first time, the image had a public key that it shared with my PC and then my PC expected to see the same public key for any future SSH connection to that IP address. When I put a new image on the RPI, I had a new public key that didn't match what my PC was expecting. It was an imposter!

Steps to reproduce the problem

  1. Go through the first steps of creating a treehouses image and booting up the RPI
  2. SSH into the RPI
  3. Exit SSH and disconnect/power down RPI
  4. Make a new treehouses image on an sd card and put it in the same RPI
  5. Connect the RPI over ethernet and attempt to SSH

Screenshots

I forgot to get a screen shot but the error looked just like this:

sshkeyfail01

Proposed solution

The command below will clear the cached key for the IP address supplied.

ssh-keygen -R 192.168.1.123

Recommend adding the following note to sshpi.md :

Note for later: Every time you use a new image on your RPI, the known_hosts file must be updated for ssh to connect without an error. Instructions can be found on the FAQ page.

kjong commented 4 years ago

I think you're referring to a host key verification failure, in which case there are steps outlined in the faq (https://treehouses.io/#!pages/vi/faq.md) in Q11 that offers solutions.

Maybe you can add a link to that?

phamduchongan93 commented 4 years ago

@dun08015 we addressed this issue before, look at FAQ to troubleshoot ssh issue :).

john-dunbar commented 4 years ago

@kjong @phamduchongan93 Thanks for pointing that out. I would like to have a note that links to the FAQ page. Should I close this and make a new issue or just edit this one?

pattanawadee88 commented 4 years ago

@kjong @phamduchongan93 Thanks for pointing that out. I would like to have a note that links to the FAQ page. Should I close this and make a new issue or just edit this one?

you could close it or edit it for a new issue :)

john-dunbar commented 4 years ago

@pattanawadee88 it's still the same issue. I'll edit this one thanks!

john-dunbar commented 4 years ago

@kjong @pattanawadee88 I changed the note that I plan to use and updated the link to point to the FAQ page.

pattanawadee88 commented 4 years ago

@kjong @pattanawadee88 I changed the note that I plan to use and updated the link to point to the FAQ page.

yes, you could do that