yum group list
yum group install "GNOME Desktop" -y
yum group install "Server with GUI" -y
# yum group list
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: ftp.sjtu.edu.cn
* centos-sclo-rh: ftp.sjtu.edu.cn
* centos-sclo-sclo: ftp.sjtu.edu.cn
* epel: epel.mirror.angkasa.id
* extras: ftp.sjtu.edu.cn
* updates: ftp.sjtu.edu.cn
Installed Environment Groups:
Server with GUI
GNOME Desktop
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Cinnamon Desktop
MATE Desktop
Basic Web Server
Virtualization Host
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Cinnamon
Compatibility Libraries
Console Internet Tools
Development Tools
Educational Software
Electronic Lab
Fedora Packager
General Purpose Desktop
Graphical Administration Tools
Haskell
LXQt Desktop
Legacy UNIX Compatibility
MATE
Milkymist
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
TurboGears application framework
Xfce
Done
##安装
在线安装,“-y” 表示 有交互时,都选“yes”
yum -y install tigervnc-server
cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
复制后修改 /etc/systemd/system/vncserver@:1.service
/root/.vnc 而不是 /home/root/.vnc
root 用户比较特别,不带 home/
注释掉原先的 ExecStart PIDFile
修改如下
[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/usr/sbin/runuser -l -c "/usr/bin/vncserver %i"
#PIDFile=/home//.vnc/%H%i.pid
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
配置示例:
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
#ExecStart=/usr/bin/vncserver_wrapper %i
#ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable vncserver@:1.service
vncpasswd
#提示输入密码
Password:
#提示确认密码
Verify:
注意秘密是需要设置的
# vncpasswd
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
systemctl start vncserver@:1.service
或
vncserver :1
#遇到 这些报错信息,执行以下命令。Job for vncserver@:1.service failed because a configured resource limit was exceeded. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
rm -rf /tmp/.X11-unix/*
如遇这种错误,检查密码有没有设置
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2022-04-26 10:40:04 CST; 8s ago
Process: 152729 ExecStart=/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=1/FAILURE)
Process: 152725 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Main PID: 152729 (code=exited, status=1/FAILURE)
vncserver -kill :1
或
systemctl stop vncserver@:1.service
临时关闭防火墙命令。重启电脑后,防火墙自动起来。
systemctl stop firewalld
永久关闭防火墙命令。重启后,防火墙不会自动启动。
systemctl disable firewalld
默认链接端口是 IP:5901
上述连接方式 是不能共享同一桌面的。
共享当前桌面 需要使用以下命令
x0vncserver -PasswordFile=/root/.vnc/passwd display=':0.0'
IP:5900 或 IP:0
安装 基本的UI 环境
apt install ubuntu-desktop
apt install tigervnc-standalone-server -y
adduser uservncsu - uservnc
vncpasswd
注意事项
Password:Verify:Would you like to enter a view-only password (y/n)? n
启动VNC
vncserver -localhost no
查看 vnc 运行状态
# vncserver -list
TigerVNC server sessions:
X DISPLAY # RFB PORT # PROCESS ID
:1 5901 335736
关闭vnc 服务
vncserver -kill :1
https://copyfuture.com/blogs-details/20210328144344970d
sorry,that didn’t work.please try again
vi /etc/pam.d/gdm-autologin
#注释 “auth requied pam_succeed_if.so user != root quiet success”
vi /etc/pam.d/gdm-password
#注释行 “auth requied pam_succeed_if.so user != root quiet success”
无需重启机器。 即可生效