树莓派烧录系统

烧录工具

系统

步骤

  • 格式化SD卡,Raspberry Pi Imager中选Erase选项
  • 烧录目标系统
  • 将装有操作系统的SD卡插入至树莓派
  • 上电开机
  • 有外接屏幕可以看到启动过程,没有则等待几分钟后ssh远程登陆树莓派查看

树莓派联网

  • 1.外接网线
  • 2.修改网卡配置,编辑文件cd /etc/netplan/50-cloud-init.ymal
1
2
3
4
5
6
7
8
9
network:
version: 2
wifis:
wlan0:
dhcp4: true
optional: true
access-points:
wifi名称: # 名称有空格时,用双引号
password: "wifi密码"

使文件生效

1
2
netplan generate
netplan apply

Ping一下网址看是否连通

手动安装下net-tools: apt-get install net-tools,使用命令ifconfig -a查看本机IP
ssh连接树莓派

遇到问题

1.ssh连接报错

1
2
3
4
5
6
7
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
...

解决:清理之前保存的认证密钥

1
2
3
4
// 查看
ssh-keygen -l -f ~/.ssh/known_hosts
// 清理192.169.1.1的认证rsa
ssh-keygen -R 192.169.1.1

使用sshkey连接树莓派

  • 本地电脑上生成sshkey
  • 将公钥复制到树莓派上 cat ~/.ssh/pi_rsa.pub | ssh <USERNAME>@<IP-ADDRESS> 'cat >> .ssh/authorized_keys’
  • 本地电脑用sshkey连接树莓派 ssh -i ~/.ssh/pi_rsa <USERNAME>@<IP-ADDRESS>