嵌入式开发 · 2026-02-13
天下未有之大变局
ai is changing the game
环境:vs code + pio + codex
📝 真正的低代码开发
打字
ai会为你完成一切
把原理图放在目录下
io会帮你配置好的
esp32的开发如此简单
蓝牙,wifi,网页。
#!/bin/bash
# Fedora 42 + XFCE 一键开启 VNC(root 用户)
# 适用于已安装 XFCE 桌面环境的系统
set -e
DISPLAY_NUM=1
VNC_PORT=$((5900 + DISPLAY_NUM))
echo "==== 1. 安装 TigerVNC ===="
dnf install -y tigervnc-server
echo "==== 2. 设置 root 的 VNC 密码 ===="
mkdir -p /root/.vnc
vncpasswd
echo "==== 3. 创建 XFCE 启动文件 ===="
cat > /root/.vnc/xstartup <<EOF
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
exec startxfce4 &
EOF
chmod +x /root/.vnc/xstartup
echo "==== 4. 创建 systemd 服务文件 ===="
cat > /etc/systemd/system/vncserver@:${DISPLAY_NUM}.service <<EOF
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
User=root
WorkingDirectory=/root
PIDFile=/root/.vnc/%H:${DISPLAY_NUM}.pid
ExecStartPre=-/usr/bin/vncserver -kill :${DISPLAY_NUM} > /dev/null 2>&1
ExecStart=/usr/bin/vncserver :${DISPLAY_NUM}
ExecStop=/usr/bin/vncserver -kill :${DISPLAY_NUM}
[Install]
WantedBy=multi-user.target
EOF
echo "==== 5. 重新加载 systemd ===="
systemctl daemon-reload
echo "==== 6. 启动并设置开机自启 ===="
systemctl enable vncserver@:${DISPLAY_NUM}.service
systemctl start vncserver@:${DISPLAY_NUM}.service
echo "==== 7. 放行防火墙端口 ${VNC_PORT} ===="
firewall-cmd --permanent --add-port=${VNC_PORT}/tcp
firewall-cmd --reload
echo "======================================"
echo "VNC 已启动"
echo "显示号 :${DISPLAY_NUM}"
echo "连接地址: 服务器IP:${VNC_PORT}"
echo "======================================"
cat <<'EOF' > install_openssh_root.sh
#!/bin/bash
set -e
echo "==== 更新系统 ===="
dnf -y update
echo "==== 安装 OpenSSH Server ===="
dnf -y install openssh-server
echo "==== 启用并启动 sshd ===="
systemctl enable sshd
systemctl start sshd
echo "==== 修改 SSH 配置,允许 root 登录 ===="
# 允许 root 登录
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config
# 启用密码认证
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config
# 如果配置项不存在则追加
grep -q "^PermitRootLogin" /etc/ssh/sshd_config || echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
grep -q "^PasswordAuthentication" /etc/ssh/sshd_config || echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
echo "==== 重启 SSH 服务 ===="
systemctl restart sshd
echo "==== 放行防火墙 SSH 服务 ===="
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reload
echo "===================================="
echo "OpenSSH 已安装并允许 root 登录"
echo "现在可以使用:"
echo "ssh root@服务器IP"
echo "===================================="
EOF
chmod +x install_openssh_root.sh
./install_openssh_root.shzstd -dc fedora-mars-custom.img.zst | sudo dd of=/dev/sda bs=4M status=progress conv=fsync
sync