I have a raspberry running raspbian, and I want to connect over SSH, but something is happening.

On the raspberry I have run nmap and port 22 says: OPEN; the ssh process is running and fine.

But I can't connect from my windows 8.1 machine with putty, I just get connection refused.

Can anyone give me any pointers?

Edit: forgot to mention that I can both ping it and I have checked raspi-config, and it seems normal.

I had some trouble resolving dependencies with apt-get, but I reinstalled resolvconf, and that fixed it.

EDIT2: It also didn't work while disabling the Windows Firewall.

EDIT3: I can ssh the pi from the pi.

EDIT4: I just found out that my raspberry and windows box have the same ip... what?

  • Sure it is connected to the internet? Try in the command line following command : ifconfig wlan0 . Is there a real IP adress in the line inet addr? Jul 13, 2015 at 22:46
  • Can you ping from Windows machine to your Pi? Jul 13, 2015 at 23:37
  • Check if the ssh starts in boot from '/etc/init/' and check 'sudo raspi-config', you might have disabled ssh Jul 13, 2015 at 23:43
  • See edit for more info.
    – ptf
    Jul 14, 2015 at 5:14
  • I had a similar issue...finally just restarted my router (after losing 1.5 hrs debugging), and boom, magically it all works again! Symptoms were weird: all devices had internet, but could not talk to each other, and SSH refused. Restarting router fixed whatever the issue was...so it turns out it wasn't even on the PCs. Aug 24, 2016 at 2:43

4 Answers 4


Raspberry changed something since November 2016

here is the noob instruction to get this problem fixed

sudo su

1) Choose first 'update'

2) In advanced options -> expand_root file system

3) interfacing options -> ssh [enable]

4) change_locale [your country-UTF8] and if you still here, it's good to change the timezone as well

5) change the default password (don't be lazy, just do it :)

  • 1
    Please - add "change default user password" to the above list. This is probably the reason they turned it off by defaut. Sep 1, 2017 at 18:04
  • @TomaszGandor ty that's a good one Sep 7, 2017 at 16:01

So, I figured it out.

A long time ago I assigned an IP to my pi on the router, binding its mac address to the IP.

It so happened yesterday that I had the same IP when I needed the pi again. So I probably tried to connect to my windows machine from my windows machine because of the identical IP's.

What fixed it was this in cmd (on my windows box):

ipconfig /release

ipconfig /renew

yay, finally

  • 2
    Worth noting that the latest Raspbian ships with ssh disabled in the config.
    – Eddie
    Mar 4, 2017 at 3:42
  • @Eddie You saved my life man!!!!!
    – Vishal
    Apr 23, 2017 at 18:18

It might be an issue with wrong SSH key pair matching. Your client stores SSH keys of previous sessions. So if you've SSH'ed in the past with this same client to another device (or same Raspberry but with different build) on the same IP, the keys on both sides don't match. Solution: delete the keys on your client.

Putty stores SSH keys in the registry: HKEY_CURRENT_USER\SoftWare\YOU\PuTTY\SshHostKeys. If you aren't using Putty have a look at %USERPROFILE%\ssh or %USERPROFILE%\.ssh. If you're using OSX, have a look at ~/.ssh/known_hosts

  • This was a clean install on the pi, and I havent used any ssh keys with putty on this machine. This is getting difficult.
    – ptf
    Jul 14, 2015 at 19:10

It might be the windows firewall that is blocking the outbound ssh connection. Make sure port 22 is allowed out of your windows machine.

  • Ah, I didn't mention that I disabled the Windows Firewall as well, but with no luck.
    – ptf
    Jul 14, 2015 at 7:20
  • On the Pi can you ssh localhost
    – berto
    Jul 14, 2015 at 7:22
  • Yeah, that works.
    – ptf
    Jul 14, 2015 at 7:25
  • And for kicks ifconfig on the Pi and ipconfig on windows show that both systems are on the same network?
    – berto
    Jul 14, 2015 at 7:26
  • I'm not at home right now, but I remember both having the same default gateway, both being plugged into the same switch with ethernet cable, and though I didn't check my windows box's ip, the pi's ip looked like it should.
    – ptf
    Jul 14, 2015 at 7:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.