Ssh connection to raspberry pi refused

Ssh connection to raspberry pi refused

I bought a raspberry pi 3 and I’ve installed Raspbian and Openelec with Noobs. Everything works fine with Openelec, but ssh in Raspbian.

It is supossed to be enabled by default in the latest version of Raspbian, right? In fact, when I go to Rapberry Configuration menu ssh appears as enabled. Unfortunately I don’t have a keyboard so I can assure it with some terminal command, I only have a screen (tv) and a mouse. That is why I want to connect via ssh with my linux laptop.

When I try to ssh -vvv a get this:

Is there any configuration that I can write plugin in the sd card in my laptop? I’ve been reading a lot, but I can’t found a solution. I’ve looked at runlevel 2, and /etc/rc2.d/ssh/S02ssh is alredy named that way.

Any advice or help??

Thank you in advance!

Re: SSH connection refused

I, and probably thousands of other people, have found that ssh does indeed work ‘out of the box’ with Raspbian. No reconfiguration of fiddling with runlevels is needed.

Are you sure that you have correctly identified the IP address for your RPi?

Re: SSH connection refused

Re: SSH connection refused

Azrae^^l wrote: Hi all,

I bought a raspberry pi 3 and I’ve installed Raspbian and Openelec with Noobs. Everything works fine with Openelec, but ssh in Raspbian.

It is supossed to be enabled by default in the latest version of Raspbian, right? In fact, when I go to Rapberry Configuration menu ssh appears as enabled. Unfortunately I don’t have a keyboard so I can assure it with some terminal command, I only have a screen (tv) and a mouse. That is why I want to connect via ssh with my linux laptop.

When I try to ssh -vvv a get this:

This message is the same as you’d get if you were going to the wrong ip that exists but just isn’t running ssh. This might be an older router or a windows box or some phone or any number of other ip devices.

Can you ssh back to the machine you are on? Is it set up to receive incoming ssh? Do you have an android phone you could load in sftp or sshd so you could test with that? If you google rule of three, there are a lot of hits. In this case, if you have three devices (or more), you can quickly figure out which ones are working and maybe which one isn’t. With just two, is the problem your laptop or the pi? You could waste a lot of time wondering if the problem was the pi and find out it was the laptop or the other way round.

Re: SSH connection refused

Connection refused means you’ve reached a perfectly valid IP address (on your LAN segment), but port 22 isn’t open.

Three reasons that could happen
1. wrong IP address
2. sshd not running on the right IP address
3. iptables blocking your source address or your target port

More likely reason is #1.

Languages using left-hand whitespace for syntax are ridiculous

DMs sent on or LinkedIn will be answered next month.
Fake doctors — are all on my foes list.

The use of crystal balls and mind reading is prohibited.


ssh connection refused on Raspberry Pi [closed]

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 5 years ago .

The community reviewed whether to reopen this question 8 months ago and left it closed:

Original close reason(s) were not resolved

I realize this question has already been asked in some different ways, however it doesn’t seem like any of the ways I’ve come across have worked to fix this problem, so here it goes:

I’m trying to connect to my raspberry pi 3 raspbian setup via ssh on my laptop, but although I have the correct ip address, I keep getting the error:

This is unusual because when I try to ping that address, it works fine. Is there anything I can try to figure out what’s wrong?

Also keep in mind I am relatively inexperienced with bash in linux, so inclusion of any specific commands with a description of what they do would be greatly appreciated.

2 Answers 2

Apparently, the SSH server on Raspbian is now disabled by default. If there is no server listening for connections, it will not accept them. You can manually enable the SSH server according to this tutorial :

As of the November 2016 release, Raspbian has the SSH server disabled by default.

There are now multiple ways to enable it. Choose one:

From the desktop

  1. Launch Raspberry Pi Configuration from the Preferences menu
  2. Navigate to the Interfaces tab
  3. Select Enabled next to SSH
  4. Click OK

From the terminal with raspi-config

  1. Enter sudo raspi-config in a terminal window
  2. Select Interfacing Options
  3. Navigate to and select SSH
  4. Choose Yes
  5. Select Ok
  6. Choose Finish

Start the SSH service with systemctl

On a headless Raspberry Pi

For headless setup, SSH can be enabled by placing a file named ssh , without any extension, onto the boot partition of the SD card. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled, and the file is deleted. The content of the file does not matter: it could contain text, or nothing at all.


Headless SSH on Raspberry Pi3B: connection refused

Thanks for taking the time and helping me out.

Heedlessly ssh into a Raspberry Pi 3B on my Win7 platform(s).

I have two Raspberry Pi 2 B’s that I have set up in the past with no issues incl headless setup. I have a new Raspberry Pi 3B and cannot ssh into it at all. I have followed the exact same steps I have for my Pi 2B’s with exception to the image.

What I have done so far:

Download the latest Raspbian Jessie Image and format the Sd card using Win32DiskImager.

Power up the Raspberry

Ping the raspberry successfully using the Pi’s IP address.

Open Putty and enter the IP on port 22 (not that the port should matter)

At this point when I try click «Open» after having entered the Pi’s IP address I get the following error: «Connection Refused»

I then used a Screen and keyboard to boot the Pi 3B. Once booted I opened terminal and entered «sudo raspi-config», where I then enabled SSH manually.

I unplugged everything from the Pi3, plugged the LAN cable back into my laptop and Pi3 and powered up the Pi3B.

I could still ping the Pi

Using Putty and the Pi3B’s IP address I then clicked «open» and the following error came up: «Network Error: Software cause connection abort»

I have now also added a router to the setup, checked up what the ip of the pi is through the router and tried connecting with putty onto the pi, but I still get «Network Error: Connection Refused»

I am running out of ideas, any help would be appreciated. Thank you Misha

3 Answers 3

After comically large amounts of googling and hassle I found a solution here:

With the RPi3B and 11-01-2017 Raspbian Jessie combo (I dont know with which one the issue lies) one has to add a blank file named «ssh» into the boot directory of the SD card. This can be done on your Windows platform. Ensure that the file has no file extensions, because if it has any file extensions it wont work. Good practice anyway to have your file extensions showing in any case.

Hope this helps anyone else.

I have followed the exact same steps I have for my Pi 2B’s.

What you didn’t do is read the release notes of all the raspbian versions between your old and new image before following those steps. In one of them it says that you have to put a file (can be empty) with name ssh in the boot partition. Upon first boot ssh will be enabled and the file removed.

(Don’t do what I did. I put the file ‘ssh’ in the boot directory of the main partition, but that turned out to be the mount point for the (small) boot partition, hiding the file ‘ssh’ at mount and rendering the whole exercise without effect. It took me some time before I found my mistake. You have to put the file in the small boot partition itself.)


SSH connection refused even though ssh file is in /boot

My image: 2017-08-16-raspbian-stretch-lite from here
My Raspberry Pi: Raspberry Pi Zero W
My computer: Linux (Fedora 26)

What I did

  • I followed the official instructions on how to flash the img to a Micro SD card.
  • Since I don’t have an HDMI monitor, I need to be able to ssh into the device. So I followed this guide to be able to ssh into the Pi over USB. But although the Pi showed up as a new network interface that I was able to connect to, I was not able to resolve raspberrypi.local . The network interface also didn’t seem have dhcp, so I got no IP form that device.
    So I undid all the changes from that guide again. The Raspberry Pi Zero W already has WiFi, so I didn’t bother continuing going through all the hassle.

Then I edited my /etc/wpa_supplicant/wpa_supplicant.conf adding the following lines to the end of it:

It connected to my WiFi without a problem and I am able to ping it form my computer.

Now this official site says If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory. . So I added an empty file called ssh to the boot partition of the micro SD card. And since that didn’t work, I also added an empty file called ssh to the other partition of the card, but into the directory /boot . But it didn’t work either. When I say It didn’t work, I mean I can still ping it ( raspberrypi.local ), but when I try to ssh into it I get this:

Connecting to other devices via ssh works just fine in my LAN. Using the IP instead of the hostname doesn’t work either (same error). And omitting the username ( pi@ ) also results in the same error. I also tried to ssh from different devices in my LAN; same error.

Any ideas what I could be doing wrong? I mean the Raspberry Pi is quite obviously running and even connecting to my WiFi and responding to pings. It seems like the ssh service is not running or maybe there is a firewall rule blocking port 22 on that device?


Raspberry Pi: ssh connection refused

I have a problem with a raspberry pi. This morning I switched on the raspi and the ssh does not work. If I try to connect typing

the output is this:

I want to underline that I have not edited any config file or similar from yesterday, when everything worked well.

I don’t know if this can be useful but I opened the file var/log/auth.log on the raspi but there is no line about today. Just lines about yesterday. Probably ssh process does not start?

3 Answers 3

Since it seems to happen after a reboot is it possible that you didn’t fixed the IP address and the reboot made it change?

If you do ping do you have an answer?

Also I don’t understand: in your question you say that you checked var/log/auth.log on your pi and in the comments you say that you can’t make a ps on it, how is it possible?

Is there any software running in the background that could be hammering stdout?

I had a similar problem occur after I added some debugging code to the software I was testing on my pi. ssh server was running ok and listening on port 22, but always came back with ‘connection refused’. It turned out the problem was the debugging code I added to my software was spewing a lot of text to stdout, and this was running in the background initiated from an init.d script — it seems this caused a problem with ssh connection. After removing the code that was hammering stdout — the ssh server worked again.

I had a similar problem today, and found that a recent change in configuration was causing the boot sequence to stall, waiting for input. In turn, that prevented sshd from starting.

The configuration change also messed up my cmdline.txt file, so I wasn’t seeing boot messages on the screen.

First, I mounted the root volume on my laptop, and edited cmdline.txt, removing the offending console=tty1:

Then I started the Pi, and used a serial connection to repair the boot problem. A monitor, keyboard and mouse would probably have worked as well.