型号:树莓派4B 2G内存版本
系统:Raspberry Pi OS(64位) 基于Debian12
若无显示器,则:
- 烧录系统
- 单次开启ssh,新建一个ssh文本文件,删掉后缀,导入boot盘
- 打开boot盘,创建一个名为 userconf 或 userconf.txt 的文件
写入:
pi:$6$Q7yQqYO94B9fI9jn$trNI8/yvcZ8WYleaYKN5qlrzQ3AhZXLZtcNkYJlSH16xGloh2ZiM4KeAay8GSBoQ09LZI/wMOxM3qeou7uZXq.
即创建了一个pi用户,密码为raspberry
插入tf卡,启动树莓派,ssh 成功(仅此次有效),然后即可进行一系列配置。
永久开启ssh和vnc
sudo raspi-config
interface
启用root登录
1. 先用 pi 用户登陆
2. 设置 root 账号、密码
执行命令:
sudo passwd root
因为 root 默认是没有密码的,所以系统会提示设置 root 密码,第二次重复输入密码确认:
Enter new UNIX password: #输入新密码
Retype new UNIX password: #重复输入新密码
3. 启用 root 账号登录
sudo passwd --unlock root
成功更新密码提示:
passwd: password expiry information changed.
现在 root 账户可以使用了,但是不能登录,原因是ssh默认关闭 root 登陆。
4. 修改 ssh 的配置文件
打开 ssh 的配置文件:
sudo vim /etc/ssh/sshd_config
用 Ctrl + W 快捷查找
搜索 PermitRootLogin prohibit-password
在下面另加一行,添加
PermitRootLogin yes
或者
PermitRootLogin prohibit-password
改为 PermitRootLogin yes 并删掉 # 号
5. 重启树莓派,并使用 root 账户登录
sudo reboot
解决鼠标移动缓慢问题
Boot目录下的cmdline文件末尾,加一个空格再加上“
usbhid.mousepoll=0
更换软件源
查看系统架构
lsb_release -a
下文以Raspberry OS Debian12 bookworm为例
备份原文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup
vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm main contrib non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian bookworm-updates main contrib non-free-firmware
cd /etc/apt/sources.list.d
vim raspi.list
注释掉原来的,加上
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
安装一键管理脚本
curl -sS -O https://kejilion.pro/kejilion.sh && chmod +x kejilion.sh && ./kejilion.sh
此脚本在任意界面输入K唤醒
其它版本系统参考:
树莓派4B (系统版本11,bullseye)更换清华源_debian一键换清华源-CSDN博客
树莓派 4B ubuntu 20.4 更换国内源_树莓派 查看ubuntu20.04 国内镜像-CSDN博客
评论区