linux - ssh 连接在 Raspberry Pi 上被拒绝

标签 linux ssh raspberry-pi3 sshd

我意识到这个问题已经以一些不同的方式被问过,但是我遇到的任何方式似乎都没有解决这个问题,所以这里是:

我正在尝试通过笔记本电脑上的 ssh 连接到我的 raspberry pi 3 raspbian 设置,但尽管我的 IP 地址正确,但我不断收到错误消息:

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

这很不寻常,因为当我尝试 ping 该地址时,它工作正常。有什么我可以尝试找出问题所在吗?

另外请记住,我对 linux 中的 bash 相对缺乏经验,因此将不胜感激包含任何特定命令并描述它们的作用。

最佳答案

显然,Raspbian 上的 SSH 服务器现在默认禁用。如果没有服务器监听连接,它将不接受它们。可以根据这个raspberrypi.org tutorial手动开启SSH服务器:

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

现在有多种方法可以启用它。 选择一个:

从桌面

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

从终端使用 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

systemctl

启动SSH服务
sudo systemctl enable ssh
sudo systemctl start ssh

在 headless 树莓派上

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.

关于linux - ssh 连接在 Raspberry Pi 上被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41318597/

相关文章:

python - Raspberry Pi 3 - OpenCV 和 Picamera

php - 使用 phantomjs 设置 cron 作业

linux - bash 通过 ssh 连接列出 postgresql 数据库

即使 ssh 有效,Gitlab 也无法克隆存储库

javascript - 从网页在服务器上执行 shell 脚本

raspberry-pi3 - Systemctl - 步骤组生成失败

C# Raspberry pi Linux 串行端口权限即使作为 root 也被拒绝

linux - 如何处理异步套接字上所有可能的错误?

linux - 将固定宽度的文件从文本转换为 csv

linux - 在 Linux 中替换