Linux Ubuntu 16.04.6 搭建VNC 服务 记录

  • 00x0. 配置环境源

    在安装vnc 之前 ,确保当前环境能够ping通外网IP

  • 00x1.备份源文件

$:sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
  • 00x2.编辑源列表文件

$ sudo vim /etc/apt/sources.list 
将原有内容注释,添加如下内容:
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
  • 00x3.更新软件列表

    源文件配置完成后,运行如下命令进行更新列表

    $:sudo apt-get update
    

    更新软件包:

    $:sudo apt-get upgrade
    
  • 00x4.重启网络,完成配置

    $:sudo service network-manager restart
    

    tips : 重启网络后可尝试ping baidu.com 进行测试

  • 00x5.VNC 安装准备工作

    • 安装vnc 服务端

      $sudo apt-get install vnc4server
      
    • 00x5.1 -安装桌面环境

      $:sudo apt-get install --no-install-recommends ubuntu-desktop gnome-panel gnome-settings-		daemon metacity nautilus gnome-terminal -y
      
      $:sudo apt-get install vnc4server -y
      
      $:ssh -L 5901:127.0.0.1:5901 <username>@<host> -p <port>
      
      $ vncserver :1
      
    • 安装完成,第一次启动vncserver 需要设置登录密码

      $:vncserver
      

管理员

You will require a password to access yourdesktops.

Password: 123456    #输入vnc 连接密码
Verify: 123456      #确认vnc密码

xauth: creating new authority file/root/.Xauthority
New 'localhost.localdomain:1 (root)’desktop is localhost.localdomain:1
Creating default startup script/root/.vnc/xstartup
Starting applications specified in/root/.vnc/xstartup
Log file is/root/.vnc/localhost.localdomain:1.log

普通用户

su leo        #leo 是用户名
vncserver

You will require a password to access yourdesktops.

Password: 123456    #输入vnc 连接密码
Verify: 123456      #确认vnc密码

xauth: creating new authority file /home/leo/.Xauthority
New 'localhost.localdomain:2 (leo)’ desktopis localhost.localdomain:2
Creating default startup script /home/leo/.vnc/xstartup
Starting applications specified in /home/leo/.vnc/xstartup
Log file is /home/leo/.vnc/localhost.localdomain:2.log
  • 00x6.修改VNC 配置

    $ which vncserver 
    

查找vnc配置文件

$ file  /usr/bin/vncservcer

image-20200801123720515

  • 继续file 上面圈出的地方
    image-20200801125025020

  • 再次 file 上面圈出的地方
    image-20200801125731572

  • 输入 grep "59" /usr/bin/vnc4server - n 查找59端口

image-20200801130935304

  • 可以看到我的 vncPort 在212行, 对应的468 也是59 端口

  • 进行编辑端口- 找到对应的59 端口,将其修改为其它端口即可

    $ sudo vi /usr/bin/vnc4server 
    
  • 我修改的是6666

image-20200801131458801

  • 重启vnc 服务
$ vncserver -kill :1
$ vncserver :1
  • vncserver :1 的意思是在端口上面加1,并进行启动,所以我的端口此时连接为6667

  • 使用vnc软件进行连接

image-20200801131939363

  • 此时连接后,桌面可能是灰屏,需要安装桌面环境,前面已经安装了,但是需要再次进行生效
$ sudo apt-get install x-window-system-core

image-20200801132130757

  • 出现上图,则表示你已经安装了最新的版本

  • 安装桌面登录管理器

$ sudo apt-get install gdm

image-20200801132305192

  • 出现上图,则表示已经安装了最新版本

  • 安装gnome 配套设施

$ sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal
  • 修改vnc 配置
#!/bin/sh
# Uncomment the following two lines for normal desktop:
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
unset DBUS_SESSION_BUS_ADDRESS
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &
  • 重启VNC
$ vncserver -kill :1 
$ vncserver :1
  • 再次使用vnc 连接,熟悉的紫色又回来了

  • image-20200801132658566

  • 安装EasyConnect 选择合适的版本

http://mirrors.sdwu.edu.cn/easyconnect/
  • 将安装包放置任意目录-

  • 进入目录执行以下命令

$ sudo dpkg -i EasyConnect_x64_7_6_7_3.deb
# 默认安装位置/usr/share/sangfor/EasyConnect/EasyConnect
  • 运行EasyConnect
$ cd /usr/share/sangfor/EasyConnect/EasyConnect
./EasyConnect
  • 安装完成的EasyConnect 在Ubuntu 双击是打不开的,执行以上命令会有错误提示

image-20200801133306054

  • 输入以下命令进行修改
$ cd /usr/lib/x86_64-linux-gnu/
$ cp /usr/lib/x86_64-linux-gnu/libxcb.so.1 libxcb.so.1.bk
$ sudo sed -i 's/BIG-REQUESTS/_IG-REQUESTS/' libxcb.so.1
$ cd /usr/share/sangfor/EasyConnect/EasyConnect/EasyConnect

image-20200801133602576

  • 出现三行display “:1” 表示修改完成

image-20200801133909767

上一篇 下一篇