8

Zorin OS 15 Lite RealVNC多用户部署

 1 year ago
source link: https://apad.pro/ubuntu-xfce-realvnc/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Zorin OS 15 Lite RealVNC多用户部署

Zorin OS 15 Lite是基于Ubuntu 18.04的XFCE桌面版本,桌面接近Windows占用资源较少,使用RealVNC服务端还可以双向传输文件

部署好操作系统后,假设管理员用户名为user,建议先在界面创建多个需要的用户,例如 user1、user2 … user5

授予用户root权限

sudo vim /etc/sudoers
#在 root ALL=(ALL:ALL) ALL 下方添加
user1 ALL=(ALL:ALL) ALL
user2 ALL=(ALL:ALL) ALL
user3 ALL=(ALL:ALL) ALL
user4 ALL=(ALL:ALL) ALL
user5 ALL=(ALL:ALL) ALL
  1. sudo vim /etc/sudoers
  2. #在 root ALL=(ALL:ALL) ALL 下方添加
  3. user1 ALL=(ALL:ALL) ALL
  4. user2 ALL=(ALL:ALL) ALL
  5. user3 ALL=(ALL:ALL) ALL
  6. user4 ALL=(ALL:ALL) ALL
  7. user5 ALL=(ALL:ALL) ALL
sudo vim /etc/sudoers
#在 root ALL=(ALL:ALL) ALL 下方添加
user1 ALL=(ALL:ALL) ALL
user2 ALL=(ALL:ALL) ALL
user3 ALL=(ALL:ALL) ALL
user4 ALL=(ALL:ALL) ALL
user5 ALL=(ALL:ALL) ALL

下载RealVNC服务端

wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.8.0-Linux-x64.deb
  1. wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.8.0-Linux-x64.deb
wget https://www.realvnc.com/download/file/vnc.files/VNC-Server-6.8.0-Linux-x64.deb

安装RealVNC服务端

sudo dpkg -i VNC-Server-6.8.0-Linux-x64.deb
sudo vnclicense -add HN264-DB23A-XGLEB-BQCQN-T47AA
  1. sudo dpkg -i VNC-Server-6.8.0-Linux-x64.deb
  2. sudo vnclicense -add HN264-DB23A-XGLEB-BQCQN-T47AA
sudo dpkg -i VNC-Server-6.8.0-Linux-x64.deb
sudo vnclicense -add HN264-DB23A-XGLEB-BQCQN-T47AA

配置桌面环境

sudo vim /etc/vnc/xstartup.custom
#输入以下内容
#!/bin/sh
DESKTOP_SESSION=xfce
export DESKTOP_SESSION
startxfce4
vncserver-virtual -kill $DISPLAY
  1. sudo vim /etc/vnc/xstartup.custom
  2. #输入以下内容
  3. #!/bin/sh
  4. DESKTOP_SESSION=xfce
  5. export DESKTOP_SESSION
  6. startxfce4
  7. vncserver-virtual -kill $DISPLAY
sudo vim /etc/vnc/xstartup.custom
#输入以下内容
#!/bin/sh
DESKTOP_SESSION=xfce
export DESKTOP_SESSION
startxfce4
vncserver-virtual -kill $DISPLAY

赋予xstartup.custom执行权限

sudo chmod +x /etc/vnc/xstartup.custom
  1. sudo chmod +x /etc/vnc/xstartup.custom
sudo chmod +x /etc/vnc/xstartup.custom

创建VNC多用户启动脚本

sudo vim /etc/vnc/startvnc.sh
#输入以下内容
#!/bin/bash
su - user1 -c "sudo -u user1 vncserver-virtual -geometry 1920x1080 :1"
su - user2 -c "sudo -u user2 vncserver-virtual -geometry 1920x1080 :2"
su - user3 -c "sudo -u user3 vncserver-virtual -geometry 1920x1080 :3"
su - user4 -c "sudo -u user4 vncserver-virtual -geometry 1920x1080 :4"
su - user5 -c "sudo -u user5 vncserver-virtual -geometry 1920x1080 :5"
exit 0
  1. sudo vim /etc/vnc/startvnc.sh
  2. #输入以下内容
  3. #!/bin/bash
  4. su - user1 -c "sudo -u user1 vncserver-virtual -geometry 1920x1080 :1"
  5. su - user2 -c "sudo -u user2 vncserver-virtual -geometry 1920x1080 :2"
  6. su - user3 -c "sudo -u user3 vncserver-virtual -geometry 1920x1080 :3"
  7. su - user4 -c "sudo -u user4 vncserver-virtual -geometry 1920x1080 :4"
  8. su - user5 -c "sudo -u user5 vncserver-virtual -geometry 1920x1080 :5"
  9. exit 0
sudo vim /etc/vnc/startvnc.sh
#输入以下内容
#!/bin/bash
su - user1 -c "sudo -u user1 vncserver-virtual -geometry 1920x1080 :1"
su - user2 -c "sudo -u user2 vncserver-virtual -geometry 1920x1080 :2"
su - user3 -c "sudo -u user3 vncserver-virtual -geometry 1920x1080 :3"
su - user4 -c "sudo -u user4 vncserver-virtual -geometry 1920x1080 :4"
su - user5 -c "sudo -u user5 vncserver-virtual -geometry 1920x1080 :5"
exit 0

创建VNC停止脚本

sudo vim /etc/vnc/stopvnc.sh
#输入以下内容
#!/bin/bash
su - user1 -c "sudo -u user1 vncserver-virtual -kill :1"
su - user2 -c "sudo -u user2 vncserver-virtual -kill :2"
su - user3 -c "sudo -u user3 vncserver-virtual -kill :3"
su - user4 -c "sudo -u user4 vncserver-virtual -kill :4"
su - user5 -c "sudo -u user5 vncserver-virtual -kill :5"
  1. sudo vim /etc/vnc/stopvnc.sh
  2. #输入以下内容
  3. #!/bin/bash
  4. su - user1 -c "sudo -u user1 vncserver-virtual -kill :1"
  5. su - user2 -c "sudo -u user2 vncserver-virtual -kill :2"
  6. su - user3 -c "sudo -u user3 vncserver-virtual -kill :3"
  7. su - user4 -c "sudo -u user4 vncserver-virtual -kill :4"
  8. su - user5 -c "sudo -u user5 vncserver-virtual -kill :5"
sudo vim /etc/vnc/stopvnc.sh
#输入以下内容
#!/bin/bash
su - user1 -c "sudo -u user1 vncserver-virtual -kill :1"
su - user2 -c "sudo -u user2 vncserver-virtual -kill :2"
su - user3 -c "sudo -u user3 vncserver-virtual -kill :3"
su - user4 -c "sudo -u user4 vncserver-virtual -kill :4"
su - user5 -c "sudo -u user5 vncserver-virtual -kill :5"

赋予脚本执行权限

sudo chmod +x /etc/vnc/startvnc.sh
sudo chmod +x /etc/vnc/stopvnc.sh
  1. sudo chmod +x /etc/vnc/startvnc.sh
  2. sudo chmod +x /etc/vnc/stopvnc.sh
sudo chmod +x /etc/vnc/startvnc.sh
sudo chmod +x /etc/vnc/stopvnc.sh

修改系统rc.local服务

sudo vim /etc/systemd/system/rc-local.service
#添加以下内容
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target
  1. sudo vim /etc/systemd/system/rc-local.service
  2. #添加以下内容
  3. [Unit]
  4. Description=/etc/rc.local Compatibility
  5. ConditionPathExists=/etc/rc.local
  6. [Service]
  7. Type=forking
  8. ExecStart=/etc/rc.local start
  9. TimeoutSec=0
  10. StandardOutput=tty
  11. RemainAfterExit=yes
  12. SysVStartPriority=99
  13. [Install]
  14. WantedBy=multi-user.target
sudo vim /etc/systemd/system/rc-local.service
#添加以下内容
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

创建VNC自启动脚本

sudo vim /etc/rc.local
#添加以下内容
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/etc/vnc/startvnc.sh
exit 0
  1. sudo vim /etc/rc.local
  2. #添加以下内容
  3. #!/bin/sh -e
  4. # rc.local
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. # In order to enable or disable this script just change the execution
  9. # bits.
  10. # By default this script does nothing.
  11. /etc/vnc/startvnc.sh
  12. exit 0
sudo vim /etc/rc.local
#添加以下内容
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
/etc/vnc/startvnc.sh
exit 0

给rc.local加上权限

sudo chmod +x /etc/rc.local
  1. sudo chmod +x /etc/rc.local
sudo chmod +x /etc/rc.local

启动系统rc.local服务

sudo systemctl start rc-local.service
sudo systemctl enable rc-local.service
  1. sudo systemctl start rc-local.service
  2. sudo systemctl enable rc-local.service
sudo systemctl start rc-local.service
sudo systemctl enable rc-local.service

最后去RealVNC官网下载客户端,输入ip:port即可连接VNC,端口号从5901开始顺序排列,示例中的user5则是5905端口,如无法访问请开放防火墙的对应端口


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK