PC端Ubuntu18.04如何通过SSH与树莓派Ubuntu Mate18.04通信

我看了网上很多的教程,不过一直僵持了很久都没能成功,今天偶然成功了,分享一下成功的经验。因为网上很多都是Ubuntu和树莓派系统的SSH搭建,也为使用TurtleBot的机器人爱好者一个成功的案例吧。

相信大家都做过不少尝试了,之前发布过TurtleBot3-Burger+Ubuntu18.04+Melodic ROS 安装记录,我是通过HDMI线连接的显示屏做的树莓派的配置。

  1. 首先要确定PC端和树莓派都安装了ssh,指令是这样的
sudo apt-get install ssh

我还用了:

sudo apt install openssh-server

不过我不太清楚这两个命令间区别在哪,是否安装哪个就OK了,反正能成功就好!
https://ubuntu-mate.org/raspberry-pi 有这样的教程:在这里插入图片描述
翻译成能听懂的话就是上面的命令安装的没最优化,下面的SSH对树莓派做了优化。

  1. 检查PC端和树莓派Ubuntu Mate上SSH是否启用:
ps -e | grep ssh

在这里插入图片描述
这个sshd就是打开咯,还需要检查一下,这里是我的问题所在!

查看sshd是否正常运行:

systemctl status ssh

如果出现的是这样的:
在这里插入图片描述
那就是正常打开了,我的PC端最初是没错的,但是在树莓派Ubuntu Mate1804上,出现了这样↓(我成功后忘记了截错误的图,这里放一下文字)

Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_private: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_public: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: Could not load host key: /etc/ssh/ssh_
Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_private: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_public: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: Could not load host key: /etc/ssh/ssh_
Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_private: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: key_load_public: invalid format
Apr 18 13:49:12 ubuntu sshd[1195]: error: Could not load host key: /etc/ssh/ssh_
Apr 18 13:49:12 ubuntu sshd[1195]: fatal: No supported key exchange algorithms

这就是sshd出错了!
解决方法:

sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-serve

第一句命令我没用到,因为我没有这个文件,那么直接执行第二个就行了。如何在运行一下↓

systemctl status ssh

ssh -v ip这个可以打印出日志,很好用!

如果没错了,可以在PC端,执行↓

ssh [email protected].?.???

这里name是树莓派Ubuntu的用户名@后面是ip地址,即便不用usb供电,用电池供电也是亲测可用的!


如果能通过本教程成功的话或者有帮助点个赞吧各位大佬!!!

发布了30 篇原创文章 · 获赞 64 · 访问量 7748

猜你喜欢

转载自blog.csdn.net/qq_44455588/article/details/105601441