JumpZero
Posts: 1255
Joined: Thu Mar 28, 2013 7:35 pm
Location: Arcachon, France

ssh host keys generated on first boot

Sat Nov 07, 2015 2:58 pm

Hello,

Today I had a look a the recently published MagPi "conquer the command line"
https://www.raspberrypi.org/magpi-issue ... ash_v1.pdf and found on page 48 this statement:
With Raspbian, you have a pair of keys (public and
private) in /etc/ssh/. Unfortunately, they’ll be the same as those
held by everyone else with a copy of the Raspbian image that you
downloaded.
I am very surprised by this. I have checked on 3 pi running Raspbian Wheezy all of them have different host keys. Also I remember when I re-installed a fresh Raspbian and ssh'ing to it from another computer I received a message about the host key has changed.
Also I mounted the Raspbian wheezy image (not yet switched to Jessie) and found there is only config files in /etc/ssh/ no keys at all. Hence I believe there is a script generating host keys at the very first ssh run.

Have I miss something? Is the above statement is true?

Thanks
--
Jmp0

User avatar
DougieLawson
Posts: 41900
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: ssh host keys generated on first boot

Sat Nov 07, 2015 5:48 pm

The above is 100% wrong. You've regenerated them as part of the first run of raspi-config.

The easy fix if you need to regenerate them is
sudo rm /etc/ssh/ssh_host*
sudo ssh-keygen -A
Languages using left-hand whitespace for syntax are ridiculous

DMs sent on Twitter/LinkedIn will be answered next month.
Fake doctors - are all on my foes list.

The use of crystal balls and mind reading is prohibited.

JumpZero
Posts: 1255
Joined: Thu Mar 28, 2013 7:35 pm
Location: Arcachon, France

Re: ssh host keys generated on first boot

Sun Nov 08, 2015 4:02 pm

Dougie,

Thanks for the clarification.
It makes more sense this way.
--
Jmp0

Return to “Raspberry Pi OS”