树莓派5 换源 安装xrdp 解决远程黑屏 权限弹窗

树莓派5 换源 安装xrdp 解决远程黑屏 权限弹窗

1、首先换源

打开终端输入命令,编辑 /etc/apt/sources.list.d/raspi.list 文件。

sudo nano /etc/apt/sources.list.d/raspi.list

修改更改内容为以下图片

deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main

image-20241211123330726

按Ctrrl+O 回车 保存退出

编辑 /etc/apt/sources.list 更换Debian源

sudo nano /etc/apt/sources.list

打开后更改内容

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware

image-20241211130540200

更改以后更新一下数据

sudo apt-get update
sudo apt-get upgrade

image-20241211130726670

2、树莓派安装xrdp

sudo apt-get install xrdp
sudo ervice xrdp start

提示什么都是默认Y回车,我这边已经装过了,所以没有提示,图片仅供参考

image-20241211130823153

使用Windows自带的远程桌面连接树莓派的时候会黑屏

编辑/etc/xrdp/startwm.sh

sudo nano /etc/xrdp/startwm.sh

增加两条内容

unset DBUS_SESSION_BUS_ADDRESS  # 新增
unset XDG_RUNTIME_DIR           # 新增

image-20241211131212873

完成后输入命令重启xrdp,屏幕可以正常显示画面

sudo service xrdp restart

再次测试远程桌面恢复正常

image-20241211131355540

image-20241211131436176

3、频繁弹出验密码证解决(慎用)

编辑/usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy这个文件

sudo nano /usr/share/polkit-1/actions/org.freedesktop.NetworkManager.policy

搜索此本文所有内容

<allow_any>****</allow_any>
<allow_inactive>****</allow_inactive>
<allow_active>*****</allow_active>

把里面参数全部都改为no,图片仅供参考,需要改的内容有好多。

<allow_any>no</allow_any>
<allow_inactive>no</allow_inactive>
<allow_active>no</allow_active>

image-20241211134937302

image-20241211135006469

重启树莓派

sudo reboot

重启后再次远程就把所有的密码验证都关了,相对来说安全性也就降低了。