IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    在 ubuntu 20 上使用 TigerVNC 做远程桌面

    泠泫凝发表于 2023-12-06 09:03:58
    love 0

    使用 TigerVNC 在 ubuntu 20 上(基本)完美运行远程桌面。

    这里以基础桌面为Gnome为例。

    1. 安装TigerVNC
      1
      2
      apt update 
      apt install tigervnc-standalone-server gnome-panel -y
    2. 设置VNC的访问密码
      注意,这一步执行的命令一定要在非root账户下执行,如果用root账户执行实测一定会是灰屏或黑屏。
      1
      vncpasswd
      输入两次密码然后会询问你是否创建仅观看(View-only)的密码,输入仅观看密码登录到VNC的用户只能观看远程桌面不能进行控制,可以创建也可以直接输入“n”跳过。

      如果之前装过RealVNC并卸载后再安装TigerVNC时会出现找不到该命令,此时只需要手动执行一下vncserver即可,首次运行会要求输入密码。

    3. 创建xstartup文件

      这个文件不一定就真的好使,我这好使了反正是。

      创建文件~/.vnc/xstartup,内容如下

      1
      2
      3
      4
      5
      6
      7
      8
      9
      10
      11
      12
      13
      14
      #!/bin/sh

      unset SESSION_MANAGER
      unset DBUS_SESSION_BUS_ADDRESS
      export XKL_XMODMAP_DISABLE=1
      export XDG_CURRENT_DESKTOP="GNOME-Flashback:GNOME"
      export XDG_MENU_PREFIX="gnome-flashback-"
      [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
      [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
      xsetroot -solid grey
      vncconfig -iconic &
      #gnome-terminal &
      #nautilus &
      gnome-session --session=gnome-flashback-metacity --disable-acceleration-check &

      加权限

      1
      chmod +x xstartup
    4. 运行VNC:
      1
      vncserver -localhost no
      最下面-localhost no的意思是不止监听本地。

    顺带一提可以直接在Startup Application Prefrences里面把这行命令add进去。

    返回的内容里面可以找到端口号:

    1
    2
    3
    4
    5
    6
    New 'lxnmain:1 (lxn)' desktop at :1 on machine lxnmain

    Starting applications specified in /home/lxn/.vnc/xstartup
    Log file is /home/lxn/.vnc/lxnmain:1.log

    Use xtigervncviewer -SecurityTypes VncAuth,TLSVnc -passwd /home/lxn/.vnc/passwd lxnmain:1 to connect to the VNC server.

    单引号里面的就是端口号,比如'lxnmain:1 (lxn)'的意思就是在lxnmain的设备上的5901端口上以lxn的身份开启了一个VNC服务器。

    关闭VNC Server:

    1
    vncserver -kill :1

    -kill后面接顺序号。



沪ICP备19023445号-2号
友情链接