5

I have just installed the 2012-09-18-wheezy-raspbian onto SD and plugged it into my pi. According to this question, SSH should be enabled by default. I can see the pi on the network (it responds to ping) and if I do nmap:

nmap -p 22 --open -sV 192.168.0.12
Starting Nmap 5.21 ( http://nmap.org ) at 2012-10-24 20:29 BST
Nmap scan report for 192.168.0.12
Host is up (0.00063s latency).
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 6.0p1 Debian 1 (protocol 2.0)
Service Info: OS: Linux

but when I try to ssh:

ssh -p 22 pi@192.168.0.12

I get

Read from socket failed: Connection reset by peer

I haven't got a suitable monitor so it's pretty hard to diagnose the problem. I checked an the symlinks to /etc/init.d/ssh are already in the runlevel directories as /etc/rc$i.d/S02ssh for i={1..5} (as per this answer). Any other ideas?

tdc
  • 153
  • 5

1 Answers1

3

It appears that the host key files are missing or corrupt. To correct it try this.

sudo rm /etc/ssh/ssh_host_* && sudo dpkg-reconfigure openssh-server

ref: http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&t=15814

Steve Robillard
  • 34,687
  • 17
  • 103
  • 109
  • Hmm, but how can I run this without shell access? I'll check /var/log/regen_ssh_keys.log when I get home – tdc Oct 25 '12 at 08:11
  • Can you connect a tv? – Steve Robillard Oct 25 '12 at 08:18
  • With a bit of hassle yes ... I was hoping I'd just be able to ssh straight into it as it's supposed to be enabled by default. – tdc Oct 25 '12 at 08:32
  • You could try reimaging the card and reinstalling. This seems to be a fairly rare occurance. – Steve Robillard Oct 25 '12 at 08:36
  • Ok I'll try that. It was a fresh image though (although I was overwriting a previous squeeze image), so that seems a bit odd. Unless it's something on the client side (ubuntu)?? – tdc Oct 25 '12 at 08:40
  • Solved: I redid the image, then I followed this answer http://raspberrypi.stackexchange.com/a/1706/3012 again, waited a while, and then managed to connect. Not sure what went wrong the first time around! – tdc Oct 26 '12 at 09:09