按步骤完成配置,点击每个模块右侧 ○ 标记已完成
sudo apt update
sudo apt upgrade -y
sudo apt install -y curl wget git vim htop unzip
sudo adduser ubuntu
sudo usermod -aG sudo ubuntu
su - ubuntu sudo whoami # 应输出: root
# 在本机执行(把 SERVER_IP 替换为你的服务器 IP) ssh-copy-id ubuntu@SERVER_IP
sudo rm -f /etc/apt/sources.list.d/docker.list # 清理后测试更新是否正常 sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg \ | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io \ docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world # 看到 "Hello from Docker!" 表示安装成功
sudo usermod -aG docker $USER # 重新登录 SSH 或执行以下命令使其立即生效 newgrp docker
# 安装 nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash # 重新加载 shell 配置 source ~/.bashrc # 安装最新 LTS 版 Node.js nvm install --lts # 设为默认版本 nvm alias default node
# 以 Node.js 20 LTS 为例 curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt install -y nodejs
node -v # 例: v20.18.0 npm -v # 例: 10.8.2
docker run -d \
--name beszel-agent \
--network host \
--pid host \
--restart unless-stopped \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-e KEY="YOUR_KEY" \
henrygd/beszel-agent
# 下载并安装(一键脚本) curl -sL https://raw.githubusercontent.com/henrygd/beszel/main/supplemental/scripts/install-agent.sh \ -o install-agent.sh && bash install-agent.sh
# Docker 方式 docker logs beszel-agent # 服务方式 sudo systemctl status beszel-agent
curl -fsSL https://tailscale.com/install.sh | sh
# 添加签名密钥(Ubuntu 24.04 noble) curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.noarmor.gpg \ | sudo tee /usr/share/keyrings/tailscale-archive-keyring.gpg >/dev/null curl -fsSL https://pkgs.tailscale.com/stable/ubuntu/noble.tailscale-keyring.list \ | sudo tee /etc/apt/sources.list.d/tailscale.list sudo apt update && sudo apt install -y tailscale
# 配置并启动(一次性命令) echo 'TS_DEBUG_FORCE_HTTP_ONLY=true' | sudo tee -a /etc/default/tailscaled sudo systemctl restart tailscaled sudo tailscale up \ --reset \ --force-reauth \ --accept-dns=false \ --login-server=http://YOUR_HEADSCALE_IP:41641
# 在 Headscale 服务器上执行(替换 YOUR_NODE_KEY) docker exec headscale headscale nodes register \ --key YOUR_NODE_KEY \ --user admin # 查看所有节点 docker exec headscale headscale nodes list # 重命名节点(-i 后跟节点 ID,替换 NEW_NAME) docker exec -it headscale headscale nodes rename -i NODE_ID NEW_NAME
mkdir -p ~/syncthing/config ~/syncthing/data
sudo chown -R 1000:1000 ~/syncthing/config ~/syncthing/data sudo chmod -R 775 ~/syncthing/config ~/syncthing/data
# 创建 compose 文件 cat > ~/syncthing/docker-compose.yml <<'EOF' services: syncthing: image: linuxserver/syncthing:latest container_name: syncthing hostname: syncthing environment: - PUID=1000 - PGID=1000 - TZ=Asia/Shanghai volumes: - ./config:/config - ./data:/data ports: - 8384:8384 # Web UI - 22000:22000 # 同步协议 TCP - 22000:22000/udp - 21027:21027/udp restart: unless-stopped EOF
cd ~/syncthing && docker compose up -d # 访问 Web UI: http://YOUR_SERVER_IP:8384
# 下载并安装 cloudflared curl -L --output cloudflared.deb \ https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb sudo dpkg -i cloudflared.deb rm cloudflared.deb
# 登录 Cloudflare(会弹出授权链接) cloudflared tunnel login # 创建隧道(替换 TUNNEL_NAME) cloudflared tunnel create TUNNEL_NAME # 配置 DNS 路由(替换域名和隧道 ID) cloudflared tunnel route dns TUNNEL_NAME your.domain.com
# 创建配置文件(替换 TUNNEL_ID 和域名) mkdir -p ~/.cloudflared cat > ~/.cloudflared/config.yml <<'EOF' tunnel: TUNNEL_ID credentials-file: /root/.cloudflared/TUNNEL_ID.json ingress: - hostname: your.domain.com service: http://localhost:8080 - service: http_status:404 EOF # 安装为系统服务 sudo cloudflared service install sudo systemctl start cloudflared
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \ | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \ | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update && sudo apt install caddy -y
# 编辑 /etc/caddy/Caddyfile your.domain.com { reverse_proxy localhost:8080 } # 重启服务使配置生效 sudo systemctl reload caddy
# 确认 Node.js 版本 ≥ 18 node -v
npm install -g @google/gemini-cli
# 写入 ~/.bashrc,永久生效(替换 YOUR_API_KEY) echo 'export GEMINI_API_KEY="YOUR_API_KEY"' >> ~/.bashrc source ~/.bashrc
gemini --version gemini "Hello, who are you?"
sudo apt install -y xfce4 xfce4-goodies
sudo apt install -y xrdp
sudo nano /etc/xrdp/startwm.sh
test -x /etc/X11/Xsession 的上方插入以下两行,然后 Ctrl+O 保存,Ctrl+X 退出。unset DBUS_SESSION_BUS_ADDRESS unset XDG_RUNTIME_DIR
#!/bin/sh # xrdp X session start script (c) 2015, 2017, 2021 mirabilos # published under The MirOS Licence # Rely on /etc/pam.d/xrdp-sesman using pam_env to load both # /etc/environment and /etc/default/locale to initialise the # locale and the user environment properly. if test -r /etc/profile; then . /etc/profile fi if test -r ~/.profile; then . ~/.profile fi unset DBUS_SESSION_BUS_ADDRESS unset XDG_RUNTIME_DIR test -x /etc/X11/Xsession && exec /etc/X11/Xsession exec /bin/sh /etc/X11/Xsession
sudo systemctl restart xrdp # 验证服务状态,应显示 active (running) sudo systemctl status xrdp
sudo ufw allow 3389/tcp sudo ufw status
# Windows:Win + R → 输入 mstsc → 填入 VPS IP → 连接 # macOS:App Store 安装 Microsoft Remote Desktop # Linux:使用 Remmina 客户端 登录账号:你的系统用户名(如 ubuntu) 密码:对应用户的 SSH 登录密码
# ~/.xsession 文件可能有干扰,备份后重试 mv ~/.xsession ~/.xsession.bak sudo systemctl restart xrdp
echo $XDG_SESSION_TYPE # 输出 x11 表示正常