ssh: connect to host localhost port 22: Connection refused解决方法

在通过ssh远程连接树莓派时遇到以下问题

ssh: connect to host 192.168.88.88 port 22: Connection refused

1.检查是否安装了openssh-server 如果出现了sshd,则说明安装了,反之则没安装。

ps -e|grep ssh

既然问题找到了,我们就开始用命令来安装openssh-server,命令如下:

sudo apt-get install openssh-server

安装完成后,我们再用"ps -e | grep ssh"命令来看下,openssh-server安装上去没有。也可以再次连接试试。

2.依然报错 那么可能是sshd未启动

执行命令 sudo /etc/init.d/ssh start

或者查看ssh-server配置文件:/etc/ssh/sshd_config。找到Port关键字,紧接着的就是正确端口号。

再次连接,成功

3.重启后失效 加入开机自启动

编辑/etc/rc.local文件 加入 sudo /etc/init.d/ssh start

成功

猜你喜欢

转载自blog.csdn.net/qq_41661878/article/details/129620300