在 Raspberry Pi 上拒绝 ssh 连接

我意识到这个问题已经以不同的方式被提出过,但似乎我遇到的任何方法都没有解决这个问题,所以我就这么说了:

我试图通过我的笔记本电脑上的 ssh 连接到我的覆盆子 pi 3覆盆子设置,但是尽管我有正确的 ip 地址,我仍然得到错误:

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

这很不寻常,因为当我尝试定位那个地址时,它工作得很好。有什么我能弄清楚的吗?

另外请记住,我对 linux 中的 bash 相对缺乏经验,所以如果能包含任何具体的命令,并说明它们的功能,我将不胜感激。

161913 次浏览

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.

I think pi has ssh server enabled by default. Mine have always worked out of the box. Depends which operating system version maybe.

Most of the time when it fails for me it is because the ip address has been changed. Perhaps you are pinging something else now? Also sometimes they just refuse to connect and need a restart.