温馨提示×

如何在Debian上利用TigerVNC进行远程监控

小樊
47
2025-08-28 13:50:50
栏目: 智能运维

以下是在Debian上利用TigerVNC进行远程监控的步骤:

  1. 安装TigerVNC服务器

    sudo apt update  
    sudo apt install tigervnc-standalone-server tigervnc-common  
    
  2. 设置VNC密码

    vncpasswd  
    

    按提示输入并确认密码(用于远程连接认证)。

  3. 配置VNC服务器

    • 编辑配置文件(以显示编号:1为例):
      sudo nano /etc/systemd/system/vncserver@:1.service  
      
      替换内容为(需将your_username替换为实际用户名):
      [Unit]  
      Description=Remote desktop service (VNC)  
      After=syslog.target network.target  
      [Service]  
      Type=forking  
      User=your_username  
      Group=your_username  
      WorkingDirectory=/home/your_username  
      PIDFile=/home/your_username/.vnc/%H:%i.pid  
      ExecStartPre=/usr/bin/vncserver -kill :%i > /dev/null 2>&1  
      ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i -localhost no  
      ExecStop=/usr/bin/vncserver -kill :%i  
      [Install]  
      WantedBy=multi-user.target  
      
      保存后执行:
      sudo systemctl daemon-reload  
      sudo systemctl enable vncserver@:1.service  
      sudo systemctl start vncserver@:1.service  
      
  4. 开放防火墙端口

    sudo ufw allow 5901/tcp  # 默认端口5901(对应显示编号:1)  
    sudo ufw reload  
    
  5. 客户端连接

    • 在客户端安装VNC Viewer(如TigerVNC Viewer、RealVNC Viewer)。
    • 输入服务器IP:端口(如192.168.1.100:1),使用之前设置的VNC密码连接。

可选优化

  • 配置~/.vnc/xstartup文件启动特定桌面环境(如GNOME/XFCE)。
  • 使用非root用户启动服务,提升安全性。

0