Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh connection refused on Raspberry Pi [closed]

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:

ssh: connect to host xxx.xxx.xx.x port 22: connection refused. 

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.

like image 410
Matt Avatar asked Dec 25 '16 04:12

Matt


People also ask

How do I fix connection refused on Raspberry Pi?

"Connection refused" generally means the sshd daemon isn't running, and/or isn't listening on port 22. I think you might have the wrong IP: "ipconfig" on Windows gives you the Windows IP address: you want the Raspberry Pi address. Try this: raspi-config > 8 Advanced Options > A4 SSH > make sure SSH access is "enabled"

Why is port 22 connection refused?

Sometimes while connecting to SSH servers, users often encounter “Connection refused” error by port 22. It happens because of several reasons like SSH service is not running, the port is blocked by the firewall, or the server is using a different port. It can also occur because of the IP conflict issue.


1 Answers

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 raspberrypi.org 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

sudo systemctl enable ssh sudo systemctl start ssh 

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.

like image 179
e0k Avatar answered Sep 21 '22 17:09

e0k